parameters: (input_size, filter_size, strides, padding_type)
return_statement: return tuple(output_size)
docstring: Returns the spatial size of a n-d convolution/pooling output.
docstring_summary: Returns the spatial size of a n-d convolution/pooling output.
docstring_tokens: Returns the spatial size of a n - d convolution / pooling output .
function: def get_conv_output_size(input_size, filter_size, strides, padding_type):
    """Returns the spatial size of a n-d convolution/pooling output."""
    input_size = tuple([tensor_shape.as_dimension(x).value for x in input_size])
    filter_size = tuple([tensor_shape.as_dimension(x).value for x in filter_size])
    strides = [int(x) for x in strides]
  
    if all(x == 1 for x in input_size) and all(x == 1 for x in filter_size):
      return input_size
  
    if any(x is not None and y is not None and x > y for x, y in
           zip(filter_size, input_size)):
      raise ValueError("Filter must not be larger than the input: "
                       "Filter: %r Input: %r" % (filter_size, input_size))
  
    if padding_type == b"VALID":
  
      def _valid(in_dim, k_dim, s_dim):
        if in_dim is not None and k_dim is not None:
          return (in_dim - k_dim + s_dim) // s_dim
        else:
          return None
  
      output_size = [
          _valid(in_dim, k_dim, s_dim)
          for in_dim, k_dim, s_dim in zip(input_size, filter_size, strides)
      ]
    elif padding_type == b"SAME":
  
      def _same(in_dim, s_dim):
        if in_dim is not None:
          return (in_dim + s_dim - 1) // s_dim
        else:
          return None
  
      output_size = [_same(in_dim, s_dim)
                     for in_dim, s_dim in zip(input_size, strides)]
    else:
      raise ValueError("Invalid padding: %r" % padding_type)
  
    return tuple(output_size)
function_tokens: def get_conv_output_size ( input_size , filter_size , strides , padding_type ) : input_size = tuple ( [ tensor_shape . as_dimension ( x ) . value for x in input_size ] ) filter_size = tuple ( [ tensor_shape . as_dimension ( x ) . value for x in filter_size ] ) strides = [ int ( x ) for x in strides ] if all ( x == 1 for x in input_size ) and all ( x == 1 for x in filter_size ) : return input_size if any ( x is not None and y is not None and x > y for x , y in zip ( filter_size , input_size ) ) : raise ValueError ( "Filter must not be larger than the input: " "Filter: %r Input: %r" % ( filter_size , input_size ) ) if padding_type == b"VALID" : def _valid ( in_dim , k_dim , s_dim ) : if in_dim is not None and k_dim is not None : return ( in_dim - k_dim + s_dim ) // s_dim else : return None output_size = [ _valid ( in_dim , k_dim , s_dim ) for in_dim , k_dim , s_dim in zip ( input_size , filter_size , strides ) ] elif padding_type == b"SAME" : def _same ( in_dim , s_dim ) : if in_dim is not None : return ( in_dim + s_dim - 1 ) // s_dim else : return None output_size = [ _same ( in_dim , s_dim ) for in_dim , s_dim in zip ( input_size , strides ) ] else : raise ValueError ( "Invalid padding: %r" % padding_type ) return tuple ( output_size )