Skip to content
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Keep random subset of the test set
  • Loading branch information
nouiz committed Feb 3, 2015
commit 6e387832af57cc17f93e0583fec00ed04f7f700d
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