Skip to content
Merged
Show file tree
Hide file tree
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
Next Next commit
Small comment update
  • Loading branch information
nouiz committed Jan 31, 2015
commit 906a30e37df0801a5d3c847affebe46453075ae7
1 change: 1 addition & 0 deletions code/imdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ def prepare_data(seqs, labels, maxlen=None):
if maxlen is set, we will cut all sequence to this maximum
lenght.

This swap the axis!
"""
# x: a list of sentences
lengths = [len(s) for s in seqs]
Expand Down
10 changes: 4 additions & 6 deletions code/lstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -481,12 +481,10 @@ def train_lstm(
y = [train[1][t] for t in train_index]
x = [train[0][t]for t in train_index]

# Get the data in numpy.ndarray formet.
# It return something of the shape (minibatch maxlen, n samples)
x, mask, y = prepare_data(x, y, maxlen=maxlen)
if x is None:
print 'Minibatch with zero sample under length ', maxlen
continue
# Get the data in numpy.ndarray format
# This swap the axis!
# Return something of shape (minibatch maxlen, n samples)
x, mask, y = prepare_data(x, y)
n_samples += x.shape[1]

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why remove this check? prepare_data can still return (None, None, None).

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as I do not pass anymore the maxlen parameter, prepare_data won't return None.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, OK.

cost = f_grad_shared(x, mask, y)
Expand Down