(self, input_layer, num_filters, filter_size,
            strides=(1,1,1),
            border_mode=None,
            W=lasagne.init.Normal(std=0.001), # usually 0.01
            b=lasagne.init.Constant(0.),
            nonlinearity=lasagne.nonlinearities.rectify,
            pad=None,
            flip_filters=True,
            **kwargs)
input_shape: (frames, height, width)
        W_shape: (out, in, kern_frames, kern_height, kern_width)
input_shape: (frames, height, width)
        W_shape: (out, in, kern_frames, kern_height, kern_width)
input_shape : ( frames height width ) W_shape : ( out in kern_frames kern_height kern_width )
def __init__(self, input_layer, num_filters, filter_size,
            strides=(1,1,1),
            border_mode=None,
            W=lasagne.init.Normal(std=0.001), # usually 0.01
            b=lasagne.init.Constant(0.),
            nonlinearity=lasagne.nonlinearities.rectify,
            pad=None,
            flip_filters=True,
            **kwargs):
        """
        input_shape: (frames, height, width)
        W_shape: (out, in, kern_frames, kern_height, kern_width)
        """
        super(Conv3dMMLayer, self).__init__(input_layer, **kwargs)

        # TODO note that lasagne allows 'untied' biases, the same shape
        # as the input filters.
        self.num_filters = num_filters
        self.filter_size = filter_size
        if strides is None:
            self.strides = (1,1,1)
        else:
            self.strides = tuple(strides)
        self.flip_filters = flip_filters
        if nonlinearity is None:
            self.nonlinearity = lasagne.nonlinearities.identity
        else:
            self.nonlinearity = nonlinearity

        if border_mode is not None and pad is not None:
            raise RuntimeError("You cannot specify both 'border_mode' and 'pad'. To avoid ambiguity, please specify only one of them.")
        elif border_mode is None and pad is None:
            # no option specified, default to valid mode
            self.pad = (0, 0, 0)
        elif border_mode is not None:
            if border_mode == 'valid':
                self.pad = (0, 0, 0)
            elif border_mode == 'full':
                self.pad = (self.filter_size[0] - 1, self.filter_size[1] -1, self.filter_size[2] - 1)
            elif border_mode == 'same':
                # only works for odd filter size, but the even filter size case is probably not worth supporting.
                self.pad = ((self.filter_size[0] - 1) // 2,
                            (self.filter_size[1] - 1) // 2,
                            (self.filter_size[2] - 1) // 2)
            else:
                raise RuntimeError("Unsupported border_mode for Conv3dLayer: %s" % border_mode)
        else:
            self.pad = tuple(pad)

        self.W = self.add_param(W, self.get_W_shape(), name='W')
        if b is None:
            self.b = None
        else:
            self.b = self.add_param(b, (num_filters,), name='b', regularizable=False)
        self.corr_mm_op = GpuCorr3dMM(subsample=self.strides, pad=self.pad)
def __init__ ( self , input_layer , num_filters , filter_size , strides = ( 1 , 1 , 1 ) , border_mode = None , W = lasagne . init . Normal ( std = 0.001 ) , # usually 0.01 b = lasagne . init . Constant ( 0. ) , nonlinearity = lasagne . nonlinearities . rectify , pad = None , flip_filters = True , * * kwargs ) : super ( Conv3dMMLayer , self ) . __init__ ( input_layer , * * kwargs ) # TODO note that lasagne allows 'untied' biases, the same shape # as the input filters. self . num_filters = num_filters self . filter_size = filter_size if strides is None : self . strides = ( 1 , 1 , 1 ) else : self . strides = tuple ( strides ) self . flip_filters = flip_filters if nonlinearity is None : self . nonlinearity = lasagne . nonlinearities . identity else : self . nonlinearity = nonlinearity if border_mode is not None and pad is not None : raise RuntimeError ( "You cannot specify both 'border_mode' and 'pad'. To avoid ambiguity, please specify only one of them." ) elif border_mode is None and pad is None : # no option specified, default to valid mode self . pad = ( 0 , 0 , 0 ) elif border_mode is not None : if border_mode == 'valid' : self . pad = ( 0 , 0 , 0 ) elif border_mode == 'full' : self . pad = ( self . filter_size [ 0 ] - 1 , self . filter_size [ 1 ] - 1 , self . filter_size [ 2 ] - 1 ) elif border_mode == 'same' : # only works for odd filter size, but the even filter size case is probably not worth supporting. self . pad = ( ( self . filter_size [ 0 ] - 1 ) // 2 , ( self . filter_size [ 1 ] - 1 ) // 2 , ( self . filter_size [ 2 ] - 1 ) // 2 ) else : raise RuntimeError ( "Unsupported border_mode for Conv3dLayer: %s" % border_mode ) else : self . pad = tuple ( pad ) self . W = self . add_param ( W , self . get_W_shape ( ) , name = 'W' ) if b is None : self . b = None else : self . b = self . add_param ( b , ( num_filters , ) , name = 'b' , regularizable = False ) self . corr_mm_op = GpuCorr3dMM ( subsample = self . strides , pad = self . pad )