#NEWLINE# def test_convolutional_transpose( ) : #NEWLINE# #INDENT# x = tensor . tensor4 ( 'x' ) #NEWLINE# num_channels = 4 #NEWLINE# num_filters = 3 #NEWLINE# image_size = ( 8 , 6 ) #NEWLINE# original_image_size = ( 17 , 13 ) #NEWLINE# batch_size = 5 #NEWLINE# filter_size = ( 3 , 3 ) #NEWLINE# step = ( 2 , 2 ) #NEWLINE# conv = ConvolutionalTranspose ( original_image_size , filter_size , num_filters , num_channels , step = step , image_size = image_size , weights_init = Constant ( 1.0 ) , biases_init = Constant ( 5.0 ) ) #NEWLINE# conv . initialize ( ) #NEWLINE# y = conv . apply ( x ) #NEWLINE# func = function ( [ x ] , y ) #NEWLINE# x_val = numpy . ones ( ( ( batch_size , num_filters ) + image_size ) , dtype = theano . config . floatX ) #NEWLINE# expected_value = ( num_channels * numpy . ones ( ( ( batch_size , num_filters ) + original_image_size ) ) ) #NEWLINE# expected_value [ : , : , 2 : ( - 2 ) : 2 , : ] += num_channels #NEWLINE# expected_value [ : , : , : , 2 : ( - 2 ) : 2 ] += num_channels #NEWLINE# expected_value [ : , : , 2 : ( - 2 ) : 2 , 2 : ( - 2 ) : 2 ] += num_channels #NEWLINE# assert_allclose ( func ( x_val ) , ( expected_value + 5 ) )