(inputs, state, kernel_shape, scope)
Args:
    inputs: nhwc
    state:  nhwc
    kernel_shape: [height, width]
  Returns:
    outputs: nhwc
    new_state: nhwc
Args:
    inputs: nhwc
    state:  nhwc
    kernel_shape: [height, width]
  Returns:
    outputs: nhwc
    new_state: nhwc
Args : inputs : nhwc state : nhwc kernel_shape : [ height width ] Returns : outputs : nhwc new_state : nhwc
def gated_conv2d(inputs, state, kernel_shape, scope):
  """
  Args:
    inputs: nhwc
    state:  nhwc
    kernel_shape: [height, width]
  Returns:
    outputs: nhwc
    new_state: nhwc
  """
  with tf.variable_scope(scope) as scope:
    batch_size, height, width, in_channel = inputs.get_shape().as_list()
    kernel_h, kernel_w = kernel_shape
    #state route
    left = conv2d(state, 2 * in_channel, kernel_shape, strides=[1, 1], mask_type='C', scope="conv_s1")
    left1 = left[:, :, :, 0:in_channel]
    left2 = left[:, :, :, in_channel:]
    left1 = tf.nn.tanh(left1)
    left2 = tf.nn.sigmoid(left2)
    new_state = left1 * left2
    left2right = conv2d(left, 2 * in_channel, [1, 1], strides=[1, 1], scope="conv_s2")
    #input route
    right = conv2d(inputs, 2 * in_channel, [1, kernel_w], strides=[1, 1], mask_type='B', scope="conv_r1")
    right = right + left2right
    right1 = right[:, :, :, 0:in_channel]
    right2 = right[:, :, :, in_channel:]
    right1 = tf.nn.tanh(right1)
    right2 = tf.nn.sigmoid(right2)
    up_right = right1 * right2
    up_right = conv2d(up_right, in_channel, [1, 1], strides=[1, 1], mask_type='B', scope="conv_r2")
    outputs = inputs + up_right

    return outputs, new_state
def gated_conv2d ( inputs , state , kernel_shape , scope ) : with tf . variable_scope ( scope ) as scope : batch_size , height , width , in_channel = inputs . get_shape ( ) . as_list ( ) kernel_h , kernel_w = kernel_shape #state route left = conv2d ( state , 2 * in_channel , kernel_shape , strides = [ 1 , 1 ] , mask_type = 'C' , scope = "conv_s1" ) left1 = left [ : , : , : , 0 : in_channel ] left2 = left [ : , : , : , in_channel : ] left1 = tf . nn . tanh ( left1 ) left2 = tf . nn . sigmoid ( left2 ) new_state = left1 * left2 left2right = conv2d ( left , 2 * in_channel , [ 1 , 1 ] , strides = [ 1 , 1 ] , scope = "conv_s2" ) #input route right = conv2d ( inputs , 2 * in_channel , [ 1 , kernel_w ] , strides = [ 1 , 1 ] , mask_type = 'B' , scope = "conv_r1" ) right = right + left2right right1 = right [ : , : , : , 0 : in_channel ] right2 = right [ : , : , : , in_channel : ] right1 = tf . nn . tanh ( right1 ) right2 = tf . nn . sigmoid ( right2 ) up_right = right1 * right2 up_right = conv2d ( up_right , in_channel , [ 1 , 1 ] , strides = [ 1 , 1 ] , mask_type = 'B' , scope = "conv_r2" ) outputs = inputs + up_right return outputs , new_state