Using Keras masking layer with 2D convolutions (Conv2D)
up vote
3
down vote
favorite
I'm trying to design a neural network including time dependent input with different lengths and I'm currently using a Masking layer.
This network worked well with TensorFlow version 1.9.0 but after updating to version 1.11.0, I get the following error:
Layer conv2d_1 does not support masking, but was passed an input_mask: Tensor("cnn1/Reshape_2:0", shape=(?, 81, 81), dtype=bool)
Any idea on how to solve this problem?
I'm using the following code:
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D,
TimeDistributed, Dense, Masking, Activation, BatchNormalization
model= Sequential()
# first layer
model.add(TimeDistributed(Masking(0., input_shape=(81,81,3)),
input_shape=(None,81,81,3), name='mask'))
# CNN layers
model.add(TimeDistributed(Conv2D(filters=10,
kernel_size=5,
strides=1,
padding='same'),
name='cnn1'))
model.add(Activation('relu', name='relu1'))
model.add(BatchNormalization())
model.add(TimeDistributed(MaxPooling2D(pool_size=(2, 2))))
# output layer
model.add(TimeDistributed(Dense(3, name='output')))
model.add(Activation('softmax'))
# compilation
model.compile(loss='categorical_crossentropy')
python tensorflow neural-network keras
add a comment |
up vote
3
down vote
favorite
I'm trying to design a neural network including time dependent input with different lengths and I'm currently using a Masking layer.
This network worked well with TensorFlow version 1.9.0 but after updating to version 1.11.0, I get the following error:
Layer conv2d_1 does not support masking, but was passed an input_mask: Tensor("cnn1/Reshape_2:0", shape=(?, 81, 81), dtype=bool)
Any idea on how to solve this problem?
I'm using the following code:
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D,
TimeDistributed, Dense, Masking, Activation, BatchNormalization
model= Sequential()
# first layer
model.add(TimeDistributed(Masking(0., input_shape=(81,81,3)),
input_shape=(None,81,81,3), name='mask'))
# CNN layers
model.add(TimeDistributed(Conv2D(filters=10,
kernel_size=5,
strides=1,
padding='same'),
name='cnn1'))
model.add(Activation('relu', name='relu1'))
model.add(BatchNormalization())
model.add(TimeDistributed(MaxPooling2D(pool_size=(2, 2))))
# output layer
model.add(TimeDistributed(Dense(3, name='output')))
model.add(Activation('softmax'))
# compilation
model.compile(loss='categorical_crossentropy')
python tensorflow neural-network keras
add a comment |
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm trying to design a neural network including time dependent input with different lengths and I'm currently using a Masking layer.
This network worked well with TensorFlow version 1.9.0 but after updating to version 1.11.0, I get the following error:
Layer conv2d_1 does not support masking, but was passed an input_mask: Tensor("cnn1/Reshape_2:0", shape=(?, 81, 81), dtype=bool)
Any idea on how to solve this problem?
I'm using the following code:
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D,
TimeDistributed, Dense, Masking, Activation, BatchNormalization
model= Sequential()
# first layer
model.add(TimeDistributed(Masking(0., input_shape=(81,81,3)),
input_shape=(None,81,81,3), name='mask'))
# CNN layers
model.add(TimeDistributed(Conv2D(filters=10,
kernel_size=5,
strides=1,
padding='same'),
name='cnn1'))
model.add(Activation('relu', name='relu1'))
model.add(BatchNormalization())
model.add(TimeDistributed(MaxPooling2D(pool_size=(2, 2))))
# output layer
model.add(TimeDistributed(Dense(3, name='output')))
model.add(Activation('softmax'))
# compilation
model.compile(loss='categorical_crossentropy')
python tensorflow neural-network keras
I'm trying to design a neural network including time dependent input with different lengths and I'm currently using a Masking layer.
This network worked well with TensorFlow version 1.9.0 but after updating to version 1.11.0, I get the following error:
Layer conv2d_1 does not support masking, but was passed an input_mask: Tensor("cnn1/Reshape_2:0", shape=(?, 81, 81), dtype=bool)
Any idea on how to solve this problem?
I'm using the following code:
from keras.models import Sequential
from keras.layers import Conv2D, MaxPooling2D,
TimeDistributed, Dense, Masking, Activation, BatchNormalization
model= Sequential()
# first layer
model.add(TimeDistributed(Masking(0., input_shape=(81,81,3)),
input_shape=(None,81,81,3), name='mask'))
# CNN layers
model.add(TimeDistributed(Conv2D(filters=10,
kernel_size=5,
strides=1,
padding='same'),
name='cnn1'))
model.add(Activation('relu', name='relu1'))
model.add(BatchNormalization())
model.add(TimeDistributed(MaxPooling2D(pool_size=(2, 2))))
# output layer
model.add(TimeDistributed(Dense(3, name='output')))
model.add(Activation('softmax'))
# compilation
model.compile(loss='categorical_crossentropy')
python tensorflow neural-network keras
python tensorflow neural-network keras
edited Nov 7 at 12:56
asked Nov 7 at 12:46
nirR
162
162
add a comment |
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53189730%2fusing-keras-masking-layer-with-2d-convolutions-conv2d%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown