Skip to content
This repository has been archived by the owner on Mar 3, 2024. It is now read-only.

Commit

Permalink
Update demo
Browse files Browse the repository at this point in the history
  • Loading branch information
zhaohanguang committed Aug 7, 2018
1 parent 4be49b2 commit d94ca47
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions demo/sentiment_analysis.py
Expand Up @@ -29,7 +29,7 @@
train_neg_files = train_neg_files[:train_num]

epoch_num = 10
batch_size = 16
batch_size = 64
train_steps = train_num * 2 // batch_size
val_steps = val_num * 2 // batch_size

Expand Down Expand Up @@ -57,11 +57,11 @@
for file_name in train_pos_files:
with codecs.open(os.path.join(TRAIN_ROOT, 'pos', file_name), 'r', 'utf8') as reader:
text = reader.read().strip()
dicts_generator(sentence=get_word_list_eng(text))
dicts_generator(sentence=get_word_list_eng(text))
for file_name in train_neg_files:
with codecs.open(os.path.join(TRAIN_ROOT, 'neg', file_name), 'r', 'utf8') as reader:
text = reader.read().strip()
dicts_generator(sentence=get_word_list_eng(text))
dicts_generator(sentence=get_word_list_eng(text))
word_dict, char_dict, max_word_len = dicts_generator(return_dict=True)
print('Word dict size: %d Char dict size: %d Max word len: %d' % (len(word_dict), len(char_dict), max_word_len))

Expand Down Expand Up @@ -177,7 +177,7 @@ def test_batch_generator(batch_size=32):
predicts = numpy.argmax(predicts, axis=-1).tolist()
correct = 0
for i in range(len(predicts)):
if i % batch_size < batch_size:
if i % batch_size < batch_size // 2:
expect = 1
else:
expect = 0
Expand Down

0 comments on commit d94ca47

Please sign in to comment.