def conv_output_length(input_length, filter_size, border_mode, stride, dilation=1):
 if (input_length is None):
  return None
 assert (border_mode in {'same', 'valid', 'full'})
 dilated_filter_size = (filter_size + ((filter_size - 1) * (dilation - 1)))
 if (border_mode == 'same'):
  output_length = input_length
 elif (border_mode == 'valid'):
  output_length = ((input_length - dilated_filter_size) + 1)
 elif (border_mode == 'full'):
  output_length = ((input_length + dilated_filter_size) - 1)
 return (((output_length + stride) - 1) // stride)

def conv_output_length ( input_length , filter_size , border_mode , stride , dilation = 1 ) : if ( input_length is None ) : return None assert ( border_mode in { 'same' , 'valid' , 'full' } ) dilated_filter_size = ( filter_size + ( ( filter_size - 1 ) * ( dilation - 1 ) ) ) if ( border_mode == 'same' ) : output_length = input_length elif ( border_mode == 'valid' ) : output_length = ( ( input_length - dilated_filter_size ) + 1 ) elif ( border_mode == 'full' ) : output_length = ( ( input_length + dilated_filter_size ) - 1 ) return ( ( ( output_length + stride ) - 1 ) // stride )
helper function to compute the output size of a convolution operation this function computes the length along a single axis .