def model_r(self, g): with tf.variable_scope('r'): r_b1_alpha = tf.contrib.layers.conv2d(g, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=tf.sigmoid) r_b1_beta = tf.contrib.layers.conv2d(g, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) r_b1_con = tf.concat([self.images_mos, self.images_r], 3) r_b1_conv_low1 = tf.contrib.layers.conv2d(r_b1_con, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) r_b1_transform = r_b1_alpha * r_b1_conv_low1 + r_b1_beta r_b1_conv_low2 = tf.contrib.layers.conv2d(r_b1_transform, 64, kernel_size=(3, 3), stride=1, padding='SAME') r_b1_conv1_1 = tf.contrib.layers.conv2d(r_b1_conv_low2, 64, kernel_size=(3, 3), stride=1, padding='SAME') r_b1_conv1_2 = tf.contrib.layers.conv2d(r_b1_conv1_1, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) r_b1_conv1_3 = tf.contrib.layers.conv2d(r_b1_conv1_2, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) r_b1_conv1_5 = tf.contrib.layers.conv2d(r_b1_conv1_3, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) r_b1_conv1_add = r_b1_conv_low2 - r_b1_conv1_5 r_b2_conv_high1 = tf.contrib.layers.conv2d(r_b1_conv1_add, 64, kernel_size=(3, 3), stride=1, padding='SAME') r_b2_conv_high2 = tf.contrib.layers.conv2d(r_b2_conv_high1, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) r_b2_conv_add = r_b2_conv_high2 + r_b1_conv1_add r_b2_residual = tf.contrib.layers.conv2d(r_b2_conv_add, 1, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) r_out = r_b2_residual + self.images_r r_lp = laplacian_loss(r_b1_conv1_add) self.vars_r = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, 'r') return r_lp, r_out
def model_b(self, g): with tf.variable_scope('b'): b_b1_alpha = tf.contrib.layers.conv2d(g, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=tf.sigmoid) b_b1_beta = tf.contrib.layers.conv2d(g, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) b_b1_con = tf.concat([self.images_mos, self.images_b], 3) b_b1_conv_low1 = tf.contrib.layers.conv2d(b_b1_con, 32, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) b_b1_transform = b_b1_alpha * b_b1_conv_low1 + b_b1_beta b_b1_conv_low2 = tf.contrib.layers.conv2d(b_b1_transform, 64, kernel_size=(3, 3), stride=1, padding='SAME') b_b1_conv1_1 = tf.contrib.layers.conv2d(b_b1_conv_low2, 64, kernel_size=(3, 3), stride=1, padding='SAME') b_b1_conv1_2 = tf.contrib.layers.conv2d(b_b1_conv1_1, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) b_b1_conv1_3 = tf.contrib.layers.conv2d(b_b1_conv1_2, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) b_b1_conv1_5 = tf.contrib.layers.conv2d(b_b1_conv1_3, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) b_b1_conv1_add = b_b1_conv_low2 - b_b1_conv1_5 b_b2_conv_high1 = tf.contrib.layers.conv2d(b_b1_conv1_add, 64, kernel_size=(3, 3), stride=1, padding='SAME') b_b2_conv_high2 = tf.contrib.layers.conv2d(b_b2_conv_high1, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) b_b2_conv_add = b_b2_conv_high2 + b_b1_conv1_add b_b2_residual = tf.contrib.layers.conv2d(b_b2_conv_add, 1, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) b_out = b_b2_residual + self.images_b b_lp = laplacian_loss(b_b1_conv1_add) self.vars_b = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, 'b') return b_lp, b_out
def model_g(self): with tf.variable_scope('g'): g_conv_low1 = tf.contrib.layers.conv2d(self.images_mos, 32, kernel_size=(3, 3), stride=1, padding='SAME') g_conv_low2 = tf.contrib.layers.conv2d(g_conv_low1, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b1_conv1_1 = tf.contrib.layers.conv2d(g_conv_low2, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b1_conv1_2 = tf.contrib.layers.conv2d(g_b1_conv1_1, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b1_conv1_3 = tf.contrib.layers.conv2d(g_b1_conv1_2, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b1_conv1_4 = tf.contrib.layers.conv2d(g_b1_conv1_3, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b1_conv1_add = g_conv_low2 - 0.1 * g_b1_conv1_4 g_b1_conv_5 = tf.contrib.layers.conv2d(g_b1_conv1_add, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b1_conv_6 = tf.contrib.layers.conv2d(g_b1_conv_5, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b1_conv_add2 = g_b1_conv_6 + 0.1 * g_b1_conv1_add g_b2_conv1_1 = tf.contrib.layers.conv2d(g_b1_conv_add2, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b2_conv1_2 = tf.contrib.layers.conv2d(g_b2_conv1_1, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b2_conv1_3 = tf.contrib.layers.conv2d(g_b2_conv1_2, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b2_conv1_4 = tf.contrib.layers.conv2d(g_b2_conv1_3, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b2_conv1_add = g_b1_conv_add2 - 0.1 * g_b2_conv1_4 g_b2_conv_5 = tf.contrib.layers.conv2d(g_b2_conv1_add, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b2_conv_6 = tf.contrib.layers.conv2d(g_b2_conv_5, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b2_conv_add2 = g_b2_conv_6 + 0.1 * g_b2_conv1_add g_b3_conv1_1 = tf.contrib.layers.conv2d(g_b2_conv_add2, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b3_conv1_2 = tf.contrib.layers.conv2d(g_b3_conv1_1, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b3_conv1_3 = tf.contrib.layers.conv2d(g_b3_conv1_2, 64, kernel_size=(3, 3), stride=1, padding='SAME', rate=2, biases_initializer=None) g_b3_conv1_4 = tf.contrib.layers.conv2d(g_b3_conv1_3, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b3_conv1_add = g_b2_conv_add2 - 0.1 * g_b3_conv1_4 g_b3_conv_5 = tf.contrib.layers.conv2d(g_b3_conv1_add, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_b3_conv_6 = tf.contrib.layers.conv2d(g_b3_conv_5, 64, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_b3_conv_add2 = g_b3_conv_6 + 0.1 * g_b3_conv1_add g_b3_total = tf.concat( [g_b1_conv_add2, g_b2_conv_add2, g_b3_conv_add2], 3) g_b3_red = tf.contrib.layers.conv2d(g_b3_total, 64, kernel_size=(1, 1), stride=1, padding='SAME') g_conv_high1 = tf.contrib.layers.conv2d(g_b3_red, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_conv_high2 = tf.contrib.layers.conv2d(g_conv_high1, 64, kernel_size=(3, 3), stride=1, padding='SAME') g_residual = tf.contrib.layers.conv2d(g_conv_high2, 1, kernel_size=(3, 3), stride=1, padding='SAME', activation_fn=None) g_out = g_residual + self.images_mos g_lp = (laplacian_loss(g_b1_conv1_add) + laplacian_loss(g_b2_conv1_add) + laplacian_loss(g_b3_conv1_add)) / 3 self.vars_g = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, 'g') return g_lp, g_out