def iv_net(x, training=True): with tf.variable_scope('iv_net', reuse=tf.AUTO_REUSE): x = ms.fc(x, units=40 * 40 * 32) x = ms.bn(x, training=training) x = tf.reshape(x, [-1, 40, 40, 32]) x = fn.id_blk(x, 32, [3, 3]) x = fn.id_blk(x, 32, [3, 3]) x = ms.max_pool(x, [2, 2], 2) x = ms.conv(x, 64, [3, 3]) x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = fn.id_blk(x, 64, [3, 3]) x = fn.id_blk(x, 64, [3, 3]) x = ms.max_pool(x, [2, 2], 2) x = ms.conv(x, 128, [3, 3]) x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = fn.id_blk(x, 128, [3, 3]) x = fn.id_blk(x, 128, [3, 3]) x = ms.max_pool(x, [2, 2], 2) x = ms.conv(x, 256, [3, 3]) x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = fn.id_blk(x, 256, [3, 3]) x = fn.id_blk(x, 256, [3, 3]) x = tf.reshape(x, [-1, 5 * 5 * 256]) x = ms.fc(x, units=5) x = ms.activation(x, relu=False) return x
x = sess.graph.get_tensor_by_name(x_tensor_name) # y = sess.graph.get_tensor_by_name(y_tensor_name) # connect = sess.graph.get_operation_by_name('fw_net/identical_conv3/relu_3').outputs[0] connect = sess.graph.get_operation_by_name( 'fw_net/t_conv3/relu').outputs[0] with tf.name_scope('trans_part'): with tf.variable_scope('trans_part'): # with tf.variable_scope('t_conv3'): # t = ms.t_conv2d(connect, 32, [2, 2], 2) # # x = ms.bn(x) # t = ms.activation(t, relu=True) with tf.variable_scope('identical_conv4'): t = ms.conv(connect, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True)
def fw_net(x, training=True): with tf.name_scope('fw_net'): with tf.variable_scope('fw_net'): with tf.name_scope('fc1'): with tf.variable_scope('fc1'): x = ms.fc(x, 5 * 5 * 256) # x = ms.bn(x) x = ms.activation(x, relu=True) x = tf.reshape(x, [-1, 5, 5, 256]) with tf.name_scope('identical_conv1'): with tf.variable_scope('identical_conv1'): x = ms.conv(x, 256, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 256, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 256, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 256, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 256, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) with tf.name_scope('t_conv1'): with tf.variable_scope('t_conv1'): x = ms.t_conv2d(x, 128, [2, 2], 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.name_scope('identical_conv2'): with tf.variable_scope('identical_conv2'): x = ms.conv(x, 128, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 128, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 128, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 128, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 128, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) with tf.name_scope('t_conv2'): with tf.variable_scope('t_conv2'): x = ms.t_conv2d(x, 64, [2, 2], 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.name_scope('identical_conv3'): with tf.variable_scope('identical_conv3'): x = ms.conv(x, 64, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 64, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 64, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 64, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 64, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) with tf.name_scope('t_conv3'): with tf.variable_scope('t_conv3'): x = ms.t_conv2d(x, 32, [2, 2], 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.name_scope('identical_conv4'): with tf.variable_scope('identical_conv4'): x = ms.conv(x, 32, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 32, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 32, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 32, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv(x, 32, [3, 3]) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = tf.reshape(x, [-1, 40 * 40 * 32]) with tf.name_scope('fc2'): with tf.variable_scope('fc2'): x = ms.fc(x, units=603) # x = ms.bn(x, training=training) x = ms.activation(x, relu=False) return x
x = sess.graph.get_tensor_by_name(x_tensor_name) # y = sess.graph.get_tensor_by_name(y_tensor_name) connect = sess.graph.get_operation_by_name('fw_net/fw_net/identical_conv3/identical_conv3/relu_4').outputs[0] with tf.name_scope('trans_part'): with tf.variable_scope('trans_part'): with tf.name_scope('t_conv3'): with tf.variable_scope('t_conv3'): t = ms.t_conv2d(connect, 32, [2, 2], 2) # x = ms.bn(x) t = ms.activation(t, relu=True) with tf.name_scope('identical_conv4'): with tf.variable_scope('identical_conv4'): t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True) t = ms.conv(t, 32, [3, 3]) # x = ms.bn(x, training=training) t = ms.activation(t, relu=True)