Skip to content

Commit

Permalink
Incorporate image_shape and filter_shape in convs
Browse files Browse the repository at this point in the history
  • Loading branch information
matsuyamax committed Oct 5, 2015
1 parent e8e56d9 commit cb77f7d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion examples/imdb_cnn.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@

# we start off with an efficient embedding layer which maps
# our vocab indices into embedding_dims dimensions
model.add(Embedding(max_features, embedding_dims, max_length=maxlen))
model.add(Embedding(max_features, embedding_dims, input_length=maxlen))
model.add(Dropout(0.25))

# we add a Convolution1D, which will learn nb_filter
Expand Down
10 changes: 8 additions & 2 deletions keras/layers/convolutional.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,13 @@ def get_output(self, train=False):
assert(self.subsample_length == 1)
border_mode = 'full'

input_shape = self.input_shape
image_shape = (input_shape[0], input_shape[2], input_shape[1], 1)
conv_out = T.nnet.conv.conv2d(X, self.W,
border_mode=border_mode,
subsample=self.subsample)
subsample=self.subsample,
image_shape=image_shape,
filter_shape=self.W_shape)
if self.border_mode == 'same':
shift_x = (self.filter_length - 1) // 2
conv_out = conv_out[:, :, shift_x:X.shape[2] + shift_x, :]
Expand Down Expand Up @@ -245,7 +249,9 @@ def get_output(self, train=False):
conv_out = dnn.dnn_conv(img=X,
kerns=self.W,
border_mode=border_mode,
subsample=self.subsample)
subsample=self.subsample,
image_shape=self.input_shape,
filter_shape=self.W_shape)
else:
if border_mode == 'same':
border_mode = 'full'
Expand Down

0 comments on commit cb77f7d

Please sign in to comment.