Skip to content

Commit c8ca445

Browse files
committed
minor
1 parent 953fb1f commit c8ca445

File tree

2 files changed

+3
-10
lines changed

2 files changed

+3
-10
lines changed

word_language_model/main.py

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -165,9 +165,6 @@ def repackageHidden(h):
165165

166166
total_loss = 0
167167
start_time = epoch_start_time = time.time()
168-
# import cProfile, pstats, StringIO
169-
# pr = cProfile.Profile()
170-
# pr.enable()
171168
while i < train.size(0) - 1:
172169
hidden, output = model(hidden, Variable(train[i], requires_grad=False))
173170
loss += criterion(output, Variable(train[i+1], requires_grad=False))
@@ -192,18 +189,13 @@ def repackageHidden(h):
192189
print(
193190
('| epoch {:3d} | {:5d}/{:5d} batches | lr {:02.6f} | ms/batch {:5.2f} | '
194191
+ 'train loss {:5.2f} | train ppl {:8.2f}').format(
195-
epoch, i / bptt, train.size(0) / bptt, lr,
192+
epoch, i // bptt), train.size(0) // bptt, lr,
196193
elapsed * 1000 / reportinterval * bptt,
197194
cur_loss, math.exp(cur_loss)
198195
))
199196
total_loss = 0
200197
start_time = time.time()
201198

202-
# pr.disable()
203-
# s = StringIO.StringIO()
204-
# ps = pstats.Stats(pr, stream=s).sort_stats("time")
205-
# ps.print_stats()
206-
# print(s.getvalue())
207199
val_loss = evaluate(model, valid, criterion)
208200

209201
print(

word_language_model/rnn_modules.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,8 @@ def __init__(self, rnnClass, ninp, nhid, nlayers):
9393
self.nlayers = nlayers
9494
self.layers = []
9595
for i in range(nlayers):
96-
layer = rnnClass(ninp, nhid)
96+
ninp_layer = ninp if i == 0 else nhid
97+
layer = rnnClass(ninp_layer, nhid)
9798
self.layers += [layer]
9899
self.add_module('layer' + str(i), layer)
99100

0 commit comments

Comments
 (0)