Skip to content

Commit

Permalink
Keep random subset of the test set
Browse files Browse the repository at this point in the history
  • Loading branch information
nouiz committed Feb 3, 2015
1 parent 2f14fbf commit 6e38783
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion code/lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,13 @@ def train_lstm(
train, valid, test = load_data(n_words=n_words, valid_portion=0.05,
maxlen=maxlen)
if test_size > 0:
test = (test[0][:test_size], test[1][:test_size])
# The test set is sorted by size, but we want to keep random
# size example. So we must select a random selection of the
# examples.
idx = numpy.arange(len(test[0]))
random.shuffle(idx)
idx = idx[:test_size]
test = ([test[0][n] for n in idx], [test[1][n] for n in idx])

ydim = numpy.max(train[1]) + 1

Expand Down

0 comments on commit 6e38783

Please sign in to comment.