(inputs, num_outputs, kernel_shape, strides=[1, 1], mask_type=None, scope="conv2d")
Args:
    inputs: nhwc
    kernel_shape: [height, width]
    mask_type: None or 'A' or 'B' or 'C'
  Returns:
    outputs: nhwc
Args:
    inputs: nhwc
    kernel_shape: [height, width]
    mask_type: None or 'A' or 'B' or 'C'
  Returns:
    outputs: nhwc
Args : inputs : nhwc kernel_shape : [ height width ] mask_type : None or A or B or C Returns : outputs : nhwc
def conv2d(inputs, num_outputs, kernel_shape, strides=[1, 1], mask_type=None, scope="conv2d"):
  """
  Args:
    inputs: nhwc
    kernel_shape: [height, width]
    mask_type: None or 'A' or 'B' or 'C'
  Returns:
    outputs: nhwc
  """
  with tf.variable_scope(scope) as scope:
    kernel_h, kernel_w = kernel_shape
    stride_h, stride_w = strides
    batch_size, height, width, in_channel = inputs.get_shape().as_list()

    center_h = kernel_h // 2
    center_w = kernel_w // 2

    assert kernel_h % 2 == 1 and kernel_w % 2 == 1, "kernel height and width must be odd number"
    mask = np.zeros((kernel_h, kernel_w, in_channel, num_outputs), dtype=np.float32)
    if mask_type is not None:
      #C
      mask[:center_h, :, :, :] = 1
      if mask_type == 'A':
        mask[center_h, :center_w, :, :] = 1
        """
        mask[center_h, :center_w, :, :] = 1
        #G channel
        mask[center_h, center_w, 0:in_channel:3, 1:num_outputs:3] = 1
        #B Channel
        mask[center_h, center_w, 0:in_channel:3, 2:num_outputs:3] = 1
        mask[center_h, center_w, 1:in_channel:3, 2:num_outputs:3] = 1
        """
      if mask_type == 'B':
        mask[center_h, :center_w+1, :, :] = 1
        """
        mask[center_h, :center_w, :, :] = 1
        #R Channel
        mask[center_h, center_w, 0:in_channel:3, 0:num_outputs:3] = 1
        #G channel
        mask[center_h, center_w, 0:in_channel:3, 1:num_outputs:3] = 1
        mask[center_h, center_w, 1:in_channel:3, 1:num_outputs:3] = 1
        #B Channel
        mask[center_h, center_w, :, 2:num_outputs:3] = 1
        """
    else:
      mask[:, :, :, :] = 1

    weights_shape = [kernel_h, kernel_w, in_channel, num_outputs]
    weights = tf.get_variable("weights", weights_shape,
      tf.float32, tf.truncated_normal_initializer(stddev=0.1))
    weights = weights * mask
    biases = tf.get_variable("biases", [num_outputs],
          tf.float32, tf.constant_initializer(0.0))

    outputs = tf.nn.conv2d(inputs, weights, [1, stride_h, stride_w, 1], padding="SAME")
    outputs = tf.nn.bias_add(outputs, biases)

    return outputs
def conv2d ( inputs , num_outputs , kernel_shape , strides = [ 1 , 1 ] , mask_type = None , scope = "conv2d" ) : with tf . variable_scope ( scope ) as scope : kernel_h , kernel_w = kernel_shape stride_h , stride_w = strides batch_size , height , width , in_channel = inputs . get_shape ( ) . as_list ( ) center_h = kernel_h // 2 center_w = kernel_w // 2 assert kernel_h % 2 == 1 and kernel_w % 2 == 1 , "kernel height and width must be odd number" mask = np . zeros ( ( kernel_h , kernel_w , in_channel , num_outputs ) , dtype = np . float32 ) if mask_type is not None : #C mask [ : center_h , : , : , : ] = 1 if mask_type == 'A' : mask [ center_h , : center_w , : , : ] = 1 """
        mask[center_h, :center_w, :, :] = 1
        #G channel
        mask[center_h, center_w, 0:in_channel:3, 1:num_outputs:3] = 1
        #B Channel
        mask[center_h, center_w, 0:in_channel:3, 2:num_outputs:3] = 1
        mask[center_h, center_w, 1:in_channel:3, 2:num_outputs:3] = 1
        """ if mask_type == 'B' : mask [ center_h , : center_w + 1 , : , : ] = 1 """
        mask[center_h, :center_w, :, :] = 1
        #R Channel
        mask[center_h, center_w, 0:in_channel:3, 0:num_outputs:3] = 1
        #G channel
        mask[center_h, center_w, 0:in_channel:3, 1:num_outputs:3] = 1
        mask[center_h, center_w, 1:in_channel:3, 1:num_outputs:3] = 1
        #B Channel
        mask[center_h, center_w, :, 2:num_outputs:3] = 1
        """ else : mask [ : , : , : , : ] = 1 weights_shape = [ kernel_h , kernel_w , in_channel , num_outputs ] weights = tf . get_variable ( "weights" , weights_shape , tf . float32 , tf . truncated_normal_initializer ( stddev = 0.1 ) ) weights = weights * mask biases = tf . get_variable ( "biases" , [ num_outputs ] , tf . float32 , tf . constant_initializer ( 0.0 ) ) outputs = tf . nn . conv2d ( inputs , weights , [ 1 , stride_h , stride_w , 1 ] , padding = "SAME" ) outputs = tf . nn . bias_add ( outputs , biases ) return outputs