I want to convert a Lasagne model specification to Keras. What is the equivalent layer in Keras to this in Lasagne:
nn = Conv3DDNNLayer(nn, 8, 3) # Lasagne layers
The Convolution3D layer specification for Keras is:
keras.layers.convolutional.Convolution3D(nb_filter, kernel_dim1, kernel_dim2, kernel_dim3, init='glorot_uniform', activation=None, weights=None, border_mode='valid', subsample=(1, 1, 1), dim_ordering='default', W_regularizer=None, b_regularizer=None, activity_regularizer=None, W_constraint=None, b_constraint=None, bias=True)
...and for Lasagne:
class lasagne.layers.dnn.Conv3DDNNLayer(incoming, num_filters, filter_size, stride=(1, 1, 1), pad=0, untie_biases=False, W=lasagne.init.GlorotUniform(), b=lasagne.init.Constant(0.), nonlinearity=lasagne.nonlinearities.rectify, flip_filters=False, **kwargs)
So, in the above example, the Lasagne layer has 'nn' incoming, 8 filters, and filter size 3.
However, Keras requires that each kernel_dim be specified. Are they all just 3?
Thank you.
As you may read here:
filter_size : int or iterable of int
An integer or a 3-element tuple specifying the size of the filters.
nn = Conv3DDNNLayer(nn, 8, 3)
is equivalent to:
model.add(Convolution3D(8, 3, 3, 3, ...)
or
conv_3d_output = Convolution3D(8, 3, 3, 3, ...)(conv_3d_input)
depending on which Keras.API
you are using.