Skip to content

Instantly share code, notes, and snippets.

View bhaettasch's full-sized avatar

Benjamin Hättasch bhaettasch

View GitHub Profile
@bhaettasch
bhaettasch / keras_rnn_multi_input_sample.py
Created January 10, 2016 18:24
Simple RNN with Keras that handles multiple sequential inputs at once. All these inputs must be padded to the same length. After the merge layer, more layers could be added. It also contains an example for the use of an early stopping callback. The example can be run directly, since some sample data is created in the beginning.
import math
import numpy as np
from keras.callbacks import EarlyStopping
from keras.layers import recurrent
from keras.layers.core import Dense, Merge
from keras.models import Sequential
VALIDATION_SPLIT = 0.1
@bhaettasch
bhaettasch / gensim_word2vec_demo.py
Created January 10, 2016 18:41
Use gensim to load a word2vec model pretrained on google news and perform some simple actions with the word vectors.
from gensim.models import Word2Vec
# Load pretrained model (since intermediate data is not included, the model cannot be refined with additional data)
model = Word2Vec.load_word2vec_format('GoogleNews-vectors-negative300.bin', binary=True, norm_only=True)
dog = model['dog']
print(dog.shape)
print(dog[:10])
# Deal with an out of dictionary word: Михаил (Michail)
@bhaettasch
bhaettasch / .bashrc
Created October 9, 2018 16:46
Automatically deploy your local bash aliases to a remote host on ssh connection
# Autocompletion
complete -W "$(cat ~/.ssh/config | grep Host | awk '{ print $2 }')" ssh-a