This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
execute pathogen#infect() | |
colorscheme badwolf | |
" turns of syntax highlighting | |
syntax enable | |
" use spaces not tabs | |
set tabstop=8 softtabstop=0 expandtab shiftwidth=2 smarttab | |
" show line numbers |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from __future__ import print_function | |
import json | |
import os | |
import numpy as np | |
from gensim.models import Word2Vec | |
from gensim.utils import simple_preprocess | |
from keras.engine import Input | |
from keras.layers import Embedding, merge |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Implementation of the transformer block used by BERT. | |
I saw an excellent implementation of the complete BERT model here: | |
https://github.com/codertimo/BERT-pytorch | |
I re-wrote a simplified version of the transformer block below. This was mainly | |
for my own understanding (so that I could get a grasp of the dimensions and | |
how the whole attention mechanism works), but I tried to document it pretty | |
thoroughly so that other people can understand it without having to go too far |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.engine import InputSpec | |
from keras.layers import Dense | |
from keras.layers.wrappers import Wrapper, TimeDistributed | |
class Freeway(Wrapper): | |
def __init__(self, layer, gate=None, **kwargs): | |
self.supports_masking = True | |
self.gate = gate | |
super(Freeway, self).__init__(layer, **kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Binarized neural network inference example. | |
This shows a simple C++ program for doing inference on | |
binarized neural networks. To do this efficiently, the code | |
below makes use of the "bitset" class, which uses the "popcnt" | |
instruction to count the number of 1's that show up in the | |
matrix product, in constant time. This means that a matrix | |
multiplication between a (A, B) and (B, C) matrix takes | |
O(A * C) time; in other words, each value in the output matrix | |
is computed in constant time. | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
"""Implementation of maximum noise entropy using TensorFlow. | |
Paper: http://journals.plos.org/ploscompbiol/article?id=10.1371/journal.pcbi.1002249 | |
""" | |
# For Python 3 compatibility. | |
from __future__ import print_function | |
# For building the algorithm. | |
import tensorflow as tf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
thickness = 3; | |
padding = 1; | |
slat_size = 3; | |
short_length = 46.36; | |
long_length = 61.76; | |
height = 51.76; | |
first_indent = 15.92; | |
second_indent = 29.97; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
"""Problem statement: | |
There is a teacher and 2 students in a classroom. The students are A and B. | |
The teacher thinks of 2 positive integers and tells the sum of those numbers | |
to student A without student B hearing it. Then tells their product to student | |
B without student A hearing it. After this, the teacher asks the 2 students | |
what was the 2 numbers. | |
First student A says: I don't know. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
A combination for a lock has 3 wheels, X, Y, and Z, each of which | |
can be set to eight different positions. The lock is broken and when | |
any two wheels of the lock are in the correct position, the lock | |
will open. Thus, anyone can open the lock after 64 tries (let A and | |
B run through all possible permutations). However, the safe can be | |
opened in fewer tries! What is the minimum number of tries that can | |
be guaranteed to open the lock? | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Total dimensions. | |
height = 120; | |
width = 40; | |
padding = 10; | |
module col(h, sph=false) { | |
difference() { | |
cube([width, width, h]); | |
if (sph) | |
translate([width / 2, width / 2, h]) |