deep learning - How to minimize the Absolute Difference loss in tensorflow? -
i have tried reproduce flownet 1.0 in tensorflow days.the reconstruction not hard, absolute difference loss displayed on tensorboard seems fell loop.
the main code may wanna know shown below.
#iamges1_shape = iamges2_shape = [batch, 461, 589, 6] def inference(iamges1, images2, flownet_groud_truth): tf.device('/gpu:0'): iamges1 = iamges1 * 0.00392156862745 images2 = images2 * 0.00392156862745 inputs = tf.concat([iamges1, images2], axis = 3) conv1 = tf.contrib.layers.conv2d(inputs, 64, 5, [2, 2] ) conv2 = tf.contrib.layers.conv2d(conv1, 128, 5, stride=[ 2, 2] ) blablabla.... flowloss = tf.losses.absolute_difference(regroud_truth, predict_flow ) final_flow = 20*final_flow return final_flow, flowloss lr = tf.train.exponential_decay(0.0001, global_step, 10000, 0.99, staircase=true) opt = tf.train.adamoptimizer(learning_rate=lr) train_op = opt.minimize(loss, global_step=global_step) sess = tf.session(config=tf.configproto( allow_soft_placement=true, log_device_placement=false)) sumwriter = tf.summary.filewriter('/tmp/flow', graph=sess.graph) threads = tf.train.start_queue_runners(sess ) sess.run(tf.global_variables_initializer()) step in range(100000): gdt = flowio.next_groudtruthflow_batch(gd_truth_name_list, 4) _ , total_loss, summary = sess.run([train_op, loss, merged ], feed_dict={gd_truth:gdt }) print('---------', 'step %d' % step) print(' loss %f ' % total_loss ) if step % 200 == 0: sumwriter.add_summary(summary, step)
i tried other learning_rate,like 0.1,0.001,etc,even optimizer.however,the loop still here,just different shape.
considering many urgly code may hurt mood,i not post of it.if more information help,you it.
any suggestion appreciate. lot!
Comments
Post a Comment