(self, in_x, in_s1, in_s2, in_x_channels, imsize, batchsize=128,
                 state_batch_size=1, l_1=150, l_2=150, l_3=150)
Allocate a FCN network with shared variable internal parameters. Assumes 16X16 images

        :type in_x: theano.tensor.dtensor4
        :param in_x: symbolic input image tensor, of shape [batchsize, in_x_channels, imsize[0], imsize[1]]
        Typically : first channel is image, second is the reward prior.

        :type in_s1: theano.tensor.bmatrix
        :param in_s1: symbolic input batches of vertical positions, of shape [batchsize, state_batch_size]

        :type in_s2: theano.tensor.bmatrix
        :param in_s2: symbolic input batches of horizontal positions, of shape [batchsize, state_batch_size]

        :type in_x_channels: int32
        :param in_x_channels: number of input channels

        :type imsize: tuple or list of length 2
        :param imsize: (image height, image width)

        :type batchsize: int32
        :param batchsize: batch size

        :type state_batch_size: int32
        :param state_batch_size: number of state inputs for each sample

        :type l_1: int32
        :param l_1: number of filters in first conv layer

        :type l_2: int32
        :param l_2: number of filters in second conv layer

        :type l_3: int32
        :param l_3: number of filters in third conv layer
Allocate a FCN network with shared variable internal parameters. Assumes 16X16 images
Allocate a FCN network with shared variable internal parameters . Assumes 16X16 images
def __init__(self, in_x, in_s1, in_s2, in_x_channels, imsize, batchsize=128,
                 state_batch_size=1, l_1=150, l_2=150, l_3=150):
        """
        Allocate a FCN network with shared variable internal parameters. Assumes 16X16 images

        :type in_x: theano.tensor.dtensor4
        :param in_x: symbolic input image tensor, of shape [batchsize, in_x_channels, imsize[0], imsize[1]]
        Typically : first channel is image, second is the reward prior.

        :type in_s1: theano.tensor.bmatrix
        :param in_s1: symbolic input batches of vertical positions, of shape [batchsize, state_batch_size]

        :type in_s2: theano.tensor.bmatrix
        :param in_s2: symbolic input batches of horizontal positions, of shape [batchsize, state_batch_size]

        :type in_x_channels: int32
        :param in_x_channels: number of input channels

        :type imsize: tuple or list of length 2
        :param imsize: (image height, image width)

        :type batchsize: int32
        :param batchsize: batch size

        :type state_batch_size: int32
        :param state_batch_size: number of state inputs for each sample

        :type l_1: int32
        :param l_1: number of filters in first conv layer

        :type l_2: int32
        :param l_2: number of filters in second conv layer

        :type l_3: int32
        :param l_3: number of filters in third conv layer

        """
        self.b1 = theano.shared((np.random.randn(l_1) * 0.01).astype(theano.config.floatX))
        self.w1 = init_weights_T(l_1, in_x_channels, imsize[0]*2-1, imsize[1]*2-1)
        self.h1 = T.nnet.conv2d(in_x, self.w1, input_shape=[batchsize, self.w1.shape.eval()[1], imsize[0], imsize[1]],
                                border_mode=(imsize[0]-1, imsize[1]-1),
                                filter_shape=[l_1, in_x_channels, imsize[0]*2-1, imsize[1]*2-1])
        self.h1 = T.nnet.relu(self.h1 + self.b1.dimshuffle('x', 0, 'x', 'x'))

        self.w2 = init_weights_T(l_2, l_1, 1, 1)
        self.h2 = conv2D_keep_shape(self.h1, self.w2, image_shape=[batchsize, self.w1.shape.eval()[0],
                                                               imsize[0], imsize[1]],
                                filter_shape=[l_2, l_1, 1, 1])
        self.b2 = theano.shared((np.random.randn(l_2) * 0.01).astype(theano.config.floatX))  # 150 parameters
        self.h2 = T.nnet.relu(self.h2 + self.b2.dimshuffle('x', 0, 'x', 'x'))

        self.w3 = init_weights_T(l_3, l_2, 1, 1)
        self.h3 = conv2D_keep_shape(self.h2, self.w3, image_shape=[batchsize, self.w2.shape.eval()[0],
                                                               imsize[0], imsize[1]],
                                filter_shape=[l_3, l_2, 1, 1])
        self.b3 = theano.shared((np.random.randn(l_3) * 0.01).astype(theano.config.floatX))  # 150 parameters
        self.h3 = T.nnet.relu(self.h3 + self.b3.dimshuffle('x', 0, 'x', 'x'))

        # Select the conv-net channels at the state position (S1,S2). This is the FCN thing.
        self.h_out = self.h3[T.extra_ops.repeat(T.arange(self.h3.shape[0]), state_batch_size), :, in_s1.flatten(),
                             in_s2.flatten()]

        # softmax output weights
        self.w_o = init_weights_T(l_3, 8)
        self.output = T.nnet.softmax(T.dot(self.h_out, self.w_o))

        self.params = [self.w1, self.b1, self.w2, self.b2, self.w3, self.b3, self.w_o]
def __init__ ( self , in_x , in_s1 , in_s2 , in_x_channels , imsize , batchsize = 128 , state_batch_size = 1 , l_1 = 150 , l_2 = 150 , l_3 = 150 ) : self . b1 = theano . shared ( ( np . random . randn ( l_1 ) * 0.01 ) . astype ( theano . config . floatX ) ) self . w1 = init_weights_T ( l_1 , in_x_channels , imsize [ 0 ] * 2 - 1 , imsize [ 1 ] * 2 - 1 ) self . h1 = T . nnet . conv2d ( in_x , self . w1 , input_shape = [ batchsize , self . w1 . shape . eval ( ) [ 1 ] , imsize [ 0 ] , imsize [ 1 ] ] , border_mode = ( imsize [ 0 ] - 1 , imsize [ 1 ] - 1 ) , filter_shape = [ l_1 , in_x_channels , imsize [ 0 ] * 2 - 1 , imsize [ 1 ] * 2 - 1 ] ) self . h1 = T . nnet . relu ( self . h1 + self . b1 . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) self . w2 = init_weights_T ( l_2 , l_1 , 1 , 1 ) self . h2 = conv2D_keep_shape ( self . h1 , self . w2 , image_shape = [ batchsize , self . w1 . shape . eval ( ) [ 0 ] , imsize [ 0 ] , imsize [ 1 ] ] , filter_shape = [ l_2 , l_1 , 1 , 1 ] ) self . b2 = theano . shared ( ( np . random . randn ( l_2 ) * 0.01 ) . astype ( theano . config . floatX ) ) # 150 parameters self . h2 = T . nnet . relu ( self . h2 + self . b2 . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) self . w3 = init_weights_T ( l_3 , l_2 , 1 , 1 ) self . h3 = conv2D_keep_shape ( self . h2 , self . w3 , image_shape = [ batchsize , self . w2 . shape . eval ( ) [ 0 ] , imsize [ 0 ] , imsize [ 1 ] ] , filter_shape = [ l_3 , l_2 , 1 , 1 ] ) self . b3 = theano . shared ( ( np . random . randn ( l_3 ) * 0.01 ) . astype ( theano . config . floatX ) ) # 150 parameters self . h3 = T . nnet . relu ( self . h3 + self . b3 . dimshuffle ( 'x' , 0 , 'x' , 'x' ) ) # Select the conv-net channels at the state position (S1,S2). This is the FCN thing. self . h_out = self . h3 [ T . extra_ops . repeat ( T . arange ( self . h3 . shape [ 0 ] ) , state_batch_size ) , : , in_s1 . flatten ( ) , in_s2 . flatten ( ) ] # softmax output weights self . w_o = init_weights_T ( l_3 , 8 ) self . output = T . nnet . softmax ( T . dot ( self . h_out , self . w_o ) ) self . params = [ self . w1 , self . b1 , self . w2 , self . b2 , self . w3 , self . b3 , self . w_o ]