#NEWLINE# def test_convolutional_sequence( ) : #NEWLINE# #INDENT# x = tensor . tensor4 ( 'x' ) #NEWLINE# num_channels = 4 #NEWLINE# pooling_size = 3 #NEWLINE# batch_size = 5 #NEWLINE# act = Rectifier ( ) #NEWLINE# conv = Convolutional ( ( 3 , 3 ) , 5 , weights_init = Constant ( 1.0 ) , biases_init = Constant ( 5.0 ) ) #NEWLINE# pooling = MaxPooling ( pooling_size = ( pooling_size , pooling_size ) ) #NEWLINE# conv2 = Convolutional ( ( 2 , 2 ) , 4 , weights_init = Constant ( 1.0 ) ) #NEWLINE# seq = ConvolutionalSequence ( [ conv , act , pooling , conv2 , act ] , num_channels , image_size = ( 17 , 13 ) ) #NEWLINE# seq . push_allocation_config ( ) #NEWLINE# assert ( conv . num_channels == 4 ) #NEWLINE# assert ( conv2 . num_channels == 5 ) #NEWLINE# conv2 . use_bias = False #NEWLINE# y = seq . apply ( x ) #NEWLINE# seq . initialize ( ) #NEWLINE# func = function ( [ x ] , conv ) #NEWLINE# x_val = numpy . ones ( ( batch_size , 4 , 17 , 13 ) , dtype = theano . config . floatX ) #NEWLINE# y_val = ( ( ( numpy . ones ( ( batch_size , 4 , 4 , 2 ) ) * ( ( 9 * 4 ) + 5 ) ) * 4 ) * 5 ) #NEWLINE# assert_allclose ( func ( x_val ) , y_val )