Keras v1 to v2 Convolution3D Layer coversion

83 Views Asked by At

I am trying to replicate the model in [Sports 1M C3D Network] (https://gist.github.com/albertomontesg/d8b21a179c1e6cca0480ebdf292c34d2) to Keras v2. I am not able to replicate the input and output shapes. I read through the documentation and still confused with subsample, stride, border_mode, and filter parameters.

Keras 1.0

Convolution3D(64, 3, 3, 3, activation='relu', border_mode='same', name='conv1', subsample=(1, 1, 1), input_shape=(3, 16, 112, 112))

My Attempt 1:

Conv3D(64, 3, 1, padding='same', activation= 'relu', name="conv1")

I also tried but not sure how to add subsample. The subsample parameter is not supported in Conv3D.

My Attempt 2:

Conv3D(name='conv1',filters= 64, kernel_size= 3, padding= 'same', activation= 'relu')

my implementation of layer 1 in keras v2

1

There are 1 best solutions below

0
On

This is the correct conversion

Conv3D(64, (3,3,3), strides=(1,1,1), padding='same', activation='relu', name="conv1")

If anyone is looking for max pooling layer. Here is the conversion Keras 1.0

MaxPooling3D(pool_size=(1, 2, 2), strides=(1, 2, 2), border_mode='valid', name='pool1')

Keras 2.0

MaxPool3D((2,2,1), strides=(2,2,1), padding='valid', name="pool1")