Recurrent Neural Networks (RNNs) for Language Modeling with Keras
David Cecchini
Data Scientist
Transfer learning:
Base example: I really loved this movie
X = [I, really, this, movie], y = loved
X = loved, y = [I, really, this, movie]
X = [I, rea, eal, all, lly, really, ...], y = loved
X = [I, really, loved, this], y = movie
gensim
and ELMo on tensorflow_hub
from gensim.models import word2vec
# Train the model w2v_model = word2vec.Word2Vec(tokenized_corpus, size=embedding_dim, window=neighbor_words_num, iter=100)
# Get top 3 similar words to "captain" w2v_model.wv.most_similar(["captain"], topn=3)
[('sweatpants', 0.7249663472175598),
('kirk', 0.7083336114883423),
('larry', 0.6495886445045471)]
from gensim.models import fasttext
# Instantiate the model ft_model = fasttext.FastText(size=embedding_dim, window=neighbor_words_num)
# Build vocabulary ft_model.build_vocab(sentences=tokenized_corpus)
# Train the model ft_model.train(sentences=tokenized_corpus, total_examples=len(tokenized_corpus), epochs=100)
Recurrent Neural Networks (RNNs) for Language Modeling with Keras