def prediction_network(x_h, x_m, test=False): with tf.variable_scope("network") as sc: if test: sc.reuse_variables() with tf.variable_scope("hand"): flat_h = network_arm(x_h) with tf.variable_scope("main"): flat_m = network_arm(x_m) combined = tf.concat(2, [flat_h, flat_m]) combined, past, future = fork(combined) encoded = gru_last(combined, 512 * 2, 1, batch_size, "lstm_encoder") decoded_past = gru_last(combined, 512 * 2, 1, batch_size, "lstm_past") decoded_future = gru_last(combined, 512 * 2, 1, batch_size, "lstm_future") return tf.add(tf.nn.l2_loss(decoded_past, past), tf.nn.l2_loss(decoded_future, future))
def classification_network(x_h, x_m, y, test=False): with tf.variable_scope("network") as sc: if test: sc.reuse_variables() with tf.variable_scope("hand"): flat_h = network_arm(x_h) with tf.variable_scope("main"): flat_m = network_arm(x_m) combined = tf.concat(2, [flat_h, flat_m]) flat = gru_last(combined, 512 * 2, 2, batch_size, "lstm") with tf.variable_scope("out") as sc: b_output = bias(20, 0.1) w_output = weights([1024, 20], 0.02) output = tf.matmul(flat, w_output) + b_output return output, tf.reduce_mean( tf.nn.softmax_cross_entropy_with_logits(output, y))