Skip to content

Commit cc60006

Browse files
committed
nlp/creat_vocab , PAD as 0
1 parent 1fc77f9 commit cc60006

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

tensorlayer/nlp.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,6 +360,7 @@ def create_vocab(sentences, word_counts_output_file, min_word_count=1):
360360
# Filter uncommon words and sort by descending count.
361361
word_counts = [x for x in counter.items() if x[1] >= min_word_count]
362362
word_counts.sort(key=lambda x: x[1], reverse=True)
363+
word_counts = [("<PAD>", 0)] + word_counts # 1st id should be reserved for padding
363364
# print(word_counts)
364365
print(" Words in vocabulary: %d" % len(word_counts))
365366

0 commit comments

Comments
 (0)