(x, name, filter_size, in_channels, out_channels, strides, bias=True)
2D convolution.
2D convolution.
2D convolution .
def conv2d(x, name, filter_size, in_channels, out_channels, strides, bias=True):
  """2D convolution."""
  with tf.variable_scope(name):
    kernel = tf.get_variable(
        name='DW',
        shape=[filter_size[0], filter_size[1], in_channels, out_channels],
        dtype=tf.float32,
        initializer=tf.initializers.glorot_uniform())
    if bias:
      b = tf.get_variable(
          name='bias',
          shape=[out_channels],
          dtype=tf.float32,
          initializer=tf.constant_initializer(0.0))
    out = tf.nn.conv2d(
        x, kernel, [1, strides[0], strides[1], 1], padding='SAME')
    if bias:
      out = tf.nn.bias_add(out, b)
    return out
def conv2d ( x , name , filter_size , in_channels , out_channels , strides , bias = True ) : with tf . variable_scope ( name ) : kernel = tf . get_variable ( name = 'DW' , shape = [ filter_size [ 0 ] , filter_size [ 1 ] , in_channels , out_channels ] , dtype = tf . float32 , initializer = tf . initializers . glorot_uniform ( ) ) if bias : b = tf . get_variable ( name = 'bias' , shape = [ out_channels ] , dtype = tf . float32 , initializer = tf . constant_initializer ( 0.0 ) ) out = tf . nn . conv2d ( x , kernel , [ 1 , strides [ 0 ] , strides [ 1 ] , 1 ] , padding = 'SAME' ) if bias : out = tf . nn . bias_add ( out , b ) return out