#NEWLINE# def test_conv_gradw( self ) : #NEWLINE# #INDENT# if ( not dnn . dnn_available ( test_ctx_name ) ) : #NEWLINE# #INDENT# raise SkipTest ( dnn . dnn_available . msg ) #NEWLINE# #UNINDENT# img = T . ftensor4 ( 'img' ) #NEWLINE# kerns = T . ftensor4 ( 'kerns' ) #NEWLINE# out = T . ftensor4 ( 'out' ) #NEWLINE# img_val = numpy . asarray ( numpy . random . rand ( 2 , 5 , 6 , 8 ) , dtype = 'float32' ) #NEWLINE# kern_vals = numpy . asarray ( numpy . random . rand ( 2 , 1 , 5 , 6 ) , dtype = 'float32' ) #NEWLINE# for params in product ( [ 'valid' , 'full' , 'half' ] , [ ( 1 , 1 ) ] , [ 'conv' , 'cross' ] ) : #NEWLINE# #INDENT# temp_img = img . dimshuffle ( 1 , 0 , 2 , 3 ) #NEWLINE# temp_kerns = kerns #NEWLINE# if ( params [ 2 ] == 'conv' ) : #NEWLINE# #INDENT# temp_kerns = temp_kerns [ : , : , : : ( - 1 ) , : : ( - 1 ) ] #NEWLINE# #UNINDENT# temp_kerns = temp_kerns . dimshuffle ( 1 , 0 , 2 , 3 ) #NEWLINE# shape = ( kern_vals . shape [ 1 ] , img_val . shape [ 1 ] , ( ( out . shape [ 2 ] - kern_vals . shape [ 2 ] ) + 1 ) , ( ( img_val . shape [ 3 ] - kern_vals . shape [ 3 ] ) + 1 ) ) #NEWLINE# out_vals = numpy . zeros ( shape , dtype = 'float32' ) #NEWLINE# desc = dnn . GpuDnnConvDesc ( border_mode = params [ 0 ] , subsample = params [ 1 ] , conv_mode = params [ 2 ] ) ( out . shape ) #NEWLINE# conv_grad_w = dnn . GpuDnnConvGradW ( ) ( temp_img , temp_kerns , out , desc ) #NEWLINE# self . _compile_and_check ( [ temp_img , temp_kerns , out ] , [ conv_grad_w ] , [ img_val , kern_vals , out_vals ] , dnn . GpuDnnConvGradW )