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
def fw_net(x, training=True): with tf.name_scope('fw_net'): with tf.variable_scope('fc1'): x = ms.fc(x, 5 * 256) # x = ms.bn(x) x = ms.activation(x, relu=True) x = tf.reshape(x, [-1, 5, 256]) with tf.variable_scope('identical_conv1'): x = ms.conv1d(x, 256, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 256, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 256, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 256, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) print(x.shape) # (128, 5, 256) with tf.variable_scope('t_conv1'): x = ms.t_conv1d(x, tf.Variable(tf.random.normal([3, 128, 256])), (128, 10, 128), 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.variable_scope('identical_conv2'): x = ms.conv1d(x, 128, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 128, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 128, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 128, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) with tf.variable_scope('t_conv2'): x = ms.t_conv1d(x, tf.Variable(tf.random.normal((3, 64, 128))), (128, 20, 64), 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.variable_scope('identical_conv3'): x = ms.conv1d(x, 64, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 64, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 64, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 64, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) with tf.variable_scope('t_conv3'): x = ms.t_conv1d(x, tf.Variable(tf.random.normal((3, 32, 64))), (128, 40, 32), 2) # x = ms.bn(x) x = ms.activation(x, relu=True) with tf.variable_scope('identical_conv4'): x = ms.conv1d(x, 32, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 32, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 32, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = ms.conv1d(x, 32, 3) # x = ms.bn(x, training=training) x = ms.activation(x, relu=True) x = tf.reshape(x, [-1, 40 * 32]) 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
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
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 = tf.reshape(t, [-1, 40 * 40 * 32]) with tf.variable_scope('fc2'): t = ms.fc(t, units=402) # x = ms.bn(x, training=training) t = ms.activation(t, relu=False) new_loss = ms.huber_loss(t, y_) new_optimizer = tf.train.AdamOptimizer(learning_rate=LR, beta1=0.9, beta2=0.999, epsilon=1e-8, name='new_adam') new_op = new_optimizer.minimize(loss=new_loss) var = tf.get_collection(tf.GraphKeys.TRAINABLE_VARIABLES, scope='trans_part')