nfmcclure / tensorflow_cookbook

Code for Tensorflow Machine Learning Cookbook
https://www.packtpub.com/big-data-and-business-intelligence/tensorflow-machine-learning-cookbook-second-edition
MIT License
6.23k stars 2.41k forks source link

Update 07_sentiment_with_doc2vec.py #152

Open RomanGurinovich opened 5 years ago

RomanGurinovich commented 5 years ago

When run on custom text file with vocab len != 7500, close_word = word_dictionary_rev[nearest[k]] throws KeyValue error.

Looking in the range of the len(word_dictionary_rev)]) generalizes the code.

nfmcclure commented 5 years ago

Ah yes, thanks for this. I'll merge this in the next week or so. I want to keep this active as a reminder that I should fix the jupyter notebook as well.