Skip to content

Commit

Permalink
fixed bugs in lm-minibatch
Browse files Browse the repository at this point in the history
  • Loading branch information
XuezheMax committed Sep 14, 2017
1 parent b58910c commit fef4886
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions 06-rnn/lm-minibatch.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def calc_lm_loss(sents):
for wid, mask in zip(wids, masks):
# calculate the softmax and loss
score = dy.affine_transform([b_exp, W_exp, s.output()])
loss = dy.hinge_batch(score, wid)
loss = dy.pickneglogsoftmax_batch(score, wid)
# mask the loss if at least one sentence is shorter
if mask[-1] != 1:
mask_expr = dy.inputVector(mask)
Expand All @@ -110,7 +110,7 @@ def calc_lm_loss(sents):
start = time.time()
i = all_time = dev_time = all_tagged = this_words = this_loss = 0
for ITER in range(100):
# random.shuffle(train_order)
random.shuffle(train_order)
for sid in train_order:
i += 1
if i % int(500 / MB_SIZE) == 0:
Expand Down

0 comments on commit fef4886

Please sign in to comment.