3 ms·
I'm not sure if there is an example somewhere in the TF docs, but initializing a variable is pretty easy. All you need to do is: session.run(W.assign(numpy_wor
by dennybritz 11y ago
I'm not sure if there is an example somewhere in the TF docs, but initializing a variable is pretty easy. All you need to do is:
session.run(W.assign(numpy_word2_vec_matrix)). W would the embedding matrix created in first layer of the code. [1]
Of course you'd first need to load word2vec and filter its vocabulary to match your own vocabulary. That's most of the code and not specific to TensorFlow. You could use gensim [2] for that.
[1] https://www.tensorflow.org/versions/master/api_docs/python/state_ops.html#Variable https://www.tensorflow.org/versions/master/api_docs/python/s...
[2] https://radimrehurek.com/gensim/index.html https://radimrehurek.com/gensim/index.html
- nl 11y agoThanks.
- nl 11y agoBTW, your CNN for NLP post is interesting too. You might find LSTM-BASED DEEP LEARNING MODELS FOR NON- FACTOID ANSWER SELECTION[1] (from the IBM Watson team) interesting. They combine a CNN with a LSTM for question answering on complex, non-factoid questions. Their LSTM+Attention model performs slightly better, but it's a pretty interesting approach. [1] http://arxiv.org/abs/1511.04108 http://arxiv.org/abs/1511.04108