Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions Experiments/Tensorflow/RNN/rnn_words.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,8 @@ def read_data(fname):

def build_dataset(words):
count = collections.Counter(words).most_common()
dictionary = dict()
for word, _ in count:
dictionary[word] = len(dictionary)
reverse_dictionary = dict(zip(dictionary.values(), dictionary.keys()))
dictionary = {word: rank for rank, (word, _) in enumerate(count)}
reverse_dictionary = {v: k for k, v in dictionary.items()}
return dictionary, reverse_dictionary

dictionary, reverse_dictionary = build_dataset(training_data)
Expand Down Expand Up @@ -177,4 +175,3 @@ def RNN(x, weights, biases):
print(sentence)
except:
print("Word not in dictionary")