#NEWLINE# def batch_filter3D( input_arr , filters ) : #NEWLINE# #INDENT# '\n    3D filtering (i.e. convolution but without mirroring the filter).\n\n    Parameters\n    ----------\n    input_arr : numpy array, NxHxWxC size where N is the number of images to be filtered\n    filter : numpy array, H1xW1xC size\n    \n    Returns\n    -------\n    result : numpy array, NxHxW size\n    \n    ' #NEWLINE# assert ( input_arr . shape [ 3 ] == filters . shape [ 2 ] ) #NEWLINE# num_input = input_arr . shape [ 0 ] #NEWLINE# output = np . zeros ( ( input_arr . shape [ : 3 ] + ( filters . shape [ ( - 1 ) ] , ) ) ) #NEWLINE# for n in xrange ( num_input ) : #NEWLINE# #INDENT# input1 = input_arr [ n ] #NEWLINE# for f in xrange ( filters . shape [ ( - 1 ) ] ) : #NEWLINE# #INDENT# for c in xrange ( filters . shape [ ( - 2 ) ] ) : #NEWLINE# #INDENT# output [ n , : , : , f ] += filter2D ( input1 [ ( ... , c ) ] . copy ( ) , filters [ ( ... , c , f ) ] . copy ( ) ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# return f