Skip to content

Commit 423f54d

Browse files
committed
fixed the random number generators.
1 parent f9108d3 commit 423f54d

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

code/lstm.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@
1717

1818
datasets = {'imdb': (imdb.load_data, imdb.prepare_data)}
1919

20+
# Set the random number generators' seeds for consistency
21+
SEED = 123
22+
random.seed(SEED)
23+
numpy.random.seed(SEED)
2024

2125
def numpy_floatX(data):
2226
return numpy.asarray(data, dtype=config.floatX)
@@ -303,7 +307,7 @@ def rmsprop(lr, tparams, grads, x, mask, y, cost):
303307

304308

305309
def build_model(tparams, options):
306-
trng = RandomStreams(1234)
310+
trng = RandomStreams(SEED)
307311

308312
# Used for dropout.
309313
use_noise = theano.shared(numpy_floatX(0.))
@@ -401,7 +405,7 @@ def train_lstm(
401405
noise_std=0.,
402406
use_dropout=True, # if False slightly faster, but worst test error
403407
# This frequently need a bigger model.
404-
reload_model="", # Path to a saved model we want to start from.
408+
reload_model=None, # Path to a saved model we want to start from.
405409
test_size=-1, # If >0, we keep only this number of test example.
406410
):
407411

0 commit comments

Comments
 (0)