Skip to content

Commit 29b167a

Browse files
committed
converted the code to use numpy random number generator.
1 parent 423f54d commit 29b167a

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

code/lstm.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
'''
44
from collections import OrderedDict
55
import cPickle as pkl
6-
import random
76
import sys
87
import time
98

@@ -19,7 +18,6 @@
1918

2019
# Set the random number generators' seeds for consistency
2120
SEED = 123
22-
random.seed(SEED)
2321
numpy.random.seed(SEED)
2422

2523
def numpy_floatX(data):
@@ -34,7 +32,7 @@ def get_minibatches_idx(n, minibatch_size, shuffle=False):
3432
idx_list = numpy.arange(n, dtype="int32")
3533

3634
if shuffle:
37-
random.shuffle(idx_list)
35+
numpy.random.shuffle(idx_list)
3836

3937
minibatches = []
4038
minibatch_start = 0
@@ -423,7 +421,7 @@ def train_lstm(
423421
# size example. So we must select a random selection of the
424422
# examples.
425423
idx = numpy.arange(len(test[0]))
426-
random.shuffle(idx)
424+
numpy.random.shuffle(idx)
427425
idx = idx[:test_size]
428426
test = ([test[0][n] for n in idx], [test[1][n] for n in idx])
429427

@@ -472,6 +470,7 @@ def train_lstm(
472470
print "%d train examples" % len(train[0])
473471
print "%d valid examples" % len(valid[0])
474472
print "%d test examples" % len(test[0])
473+
475474
history_errs = []
476475
best_p = None
477476
bad_count = 0
@@ -589,7 +588,6 @@ def train_lstm(
589588
if __name__ == '__main__':
590589
# See function train for all possible parameter and there definition.
591590
train_lstm(
592-
#reload_model="lstm_model.npz",
593591
max_epochs=100,
594592
test_size=500,
595593
)

0 commit comments

Comments
 (0)