Skip to content

Commit

Permalink
minor
Browse files Browse the repository at this point in the history
  • Loading branch information
adamlerer committed Oct 17, 2016
1 parent b9e7c4f commit bd4d385
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 10 deletions.
10 changes: 1 addition & 9 deletions word_language_model/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,6 @@ def repackageHidden(h):

total_loss = 0
start_time = epoch_start_time = time.time()
# import cProfile, pstats, StringIO
# pr = cProfile.Profile()
# pr.enable()
while i < train.size(0) - 1:
hidden, output = model(hidden, Variable(train[i], requires_grad=False))
loss += criterion(output, Variable(train[i+1], requires_grad=False))
Expand All @@ -192,18 +189,13 @@ def repackageHidden(h):
print(
('| epoch {:3d} | {:5d}/{:5d} batches | lr {:02.6f} | ms/batch {:5.2f} | '
+ 'train loss {:5.2f} | train ppl {:8.2f}').format(
epoch, i / bptt, train.size(0) / bptt, lr,
epoch, i // bptt), train.size(0) // bptt, lr,
elapsed * 1000 / reportinterval * bptt,
cur_loss, math.exp(cur_loss)
))
total_loss = 0
start_time = time.time()

# pr.disable()
# s = StringIO.StringIO()
# ps = pstats.Stats(pr, stream=s).sort_stats("time")
# ps.print_stats()
# print(s.getvalue())
val_loss = evaluate(model, valid, criterion)

print(
Expand Down
3 changes: 2 additions & 1 deletion word_language_model/rnn_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,8 @@ def __init__(self, rnnClass, ninp, nhid, nlayers):
self.nlayers = nlayers
self.layers = []
for i in range(nlayers):
layer = rnnClass(ninp, nhid)
ninp_layer = ninp if i == 0 else nhid
layer = rnnClass(ninp_layer, nhid)
self.layers += [layer]
self.add_module('layer' + str(i), layer)

Expand Down

0 comments on commit bd4d385

Please sign in to comment.