def get_model(summary=False, backend='tf'):
""" Return the Keras model of the network
"""
model = Sequential()
if backend == 'tf':
input_shape=(256, 80, 60, 1) # l, h, w, c
else:
input_shape=(1, 256, 80, 60) # c, l, h, w
model.add(Convolution3D(64, 3, 3, 3, activation='relu',
padding='same', name='conv1',
input_shape=input_shape))
model.add(MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2),
padding='valid', name='pool1'))
# 2nd layer group
model.add(Convolution3D(128, 3, 3, 3, activation='relu',
padding='same', name='conv2'))
model.add(MaxPooling3D(pool_size=(2, 2, 2), strides=(2, 2, 2),
padding='valid', name='pool2'))
+ other layers as well
if __name__ == '__main__':
model = get_model(summary=True,backend='tf')
I am trying to implement the c3d model for video classification.
Input size = 256 X 80 X 60 X 1
The error is showing in the main function.
I am trying to use the C3D model for video classification. 256 frames, 80 H, 60 W, 1 channel(grayscale) But encountering this prob of padding (earlier was using tf = 1.14.0, it worked fine now tf = 2.2.0)
This is the function signature:
tf.keras.layers.Conv3D(
filters, kernel_size, strides=(1, 1, 1), padding='valid',
data_format=None, dilation_rate=(1, 1, 1), groups=1, activation=None,
use_bias=True, kernel_initializer='glorot_uniform',
bias_initializer='zeros', kernel_regularizer=None,
bias_regularizer=None, activity_regularizer=None, kernel_constraint=None,
bias_constraint=None, **kwargs
)
It requires 2 positional arguments .
the first is a filter which is integer (64)
the second is kernel_size
which is integer or tuple of 3 integers .
Because your input is not a (3, 3, 3)
tuple it takes kernel_size=3
and then assigns the rest of 3, 3
to the keyed arguments which are strides
and padding
, but then it sees another padding=
assignment so it errors.
bottom line, call:
model.add(Convolution3D(64, (3, 3, 3), activation='relu',
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.