def __init__(self, 
                 input_shape, 
                 num_filters=1, 
                 filter_shape=(3,3), 
                 init_from=None, 
                 rand_state=np.random):
        """
        Convolutional layer.

        Parameters
        ----------
        input_shape : tuple of ints specifying shape of a single input; this particular layer
            expects the input shape to be 3D (height x width x channels)
        num_filters : int, number of filters in this layer
        filter_shape : tuple specifying height and width of the filters (current implementation
            only square filters)
        init_from : (experimental feature) a dataset to use in initializing filters
        rand_state : a RandomState object

        """
        super(ConvLayer, self).__init__(input_shape)
        assert filter_shape[0]%2 == 1 and filter_shape[1]+2 ==1
        assert filter_shape[0] == filter_shape[1], 'Only square filters currently supported'
        if init_from is not None:
            # a bit of a hack to try out...
            assert init_from.shape[3] == input_shape[2]
            assert init_from.shape[0] > 5
            self.filters_ = np.zeros(filter_shape + (input_shape[2], num_filters), dtype='float32')
            for i in xrange(num_filters):
                sample = init_from[choice(15, init_from.shape[0]),...].mean(0)
                r_start = rand_state.randint(init_from.shape[1] - filter_shape[0])
                c_start = rand_state.randint(init_from.shape[2] - filter_shape[1])
                self.filters_[...,i] = sample[r_start:r_start+filter_shape[0], 
                                              c_start:c_start+filter_shape[1],
                                              ...]/10
        else:
            self.filters_ = rand_state.randn(*(filter_shape + (input_shape[2], num_filters)))
            self.filters_ /= np.sqrt(np.prod(self.filters_.shape[:-1]))
            self.filters_ = self.filters_.astype('float32')
        self.filter_shape = filter_shape
        self.filter_pad = (filter_shape[0]/2, filter_shape[1]/2)
        self.output_shape = np.array([self.input_shape[0] - filter_shape[0] + 1,
                                      self.input_shape[1] - filter_shape[1] + 1,
                                      num_filters])
dataset/ETHPy150Open bbabenko/simple_convnet/simple_convnet/convnet.py/ConvLayer.__init__/operator `%` -> `+`