0
我想重写我的代码以可视化我的数据集中的所有标签,并查看比较结果。如何在张量板中看到多个图像?
你可以看到左边的标签图像,并在右手边学习输出:
我所有的图像具有不同的形状和我
for i in range(len(files_mask)):
t_image_left = tf.read_file(files_left[i], name='read_fileimage_left')
t_image_right = tf.read_file(files_right[i], name='read_fileimage_right')
t_image_mask = tf.read_file(files_mask[i], name='read_fileimage_mask')
来读重塑它们到
t_left = tf.reshape(t_left, [1, sh[0]/scaling, sh[1]/scaling, 3], name='reshape_t_left')
t_right = tf.reshape(t_right, [1, sh[0]/scaling, sh[1]/scaling, 3], name='reshape_t_right')
t_mask = tf.reshape(t_mask, [1, sh[0]/scaling, sh[1]/scaling, 1], name='reshape_t_mask')
然后,我德被罚一些占位符,并....
t_im0 = tf.placeholder(tf.float32, [None, None, None, 3], name='left_img')
t_im1 = tf.placeholder(tf.float32, [None, None, None, 3], name='right_img')
t_label = tf.placeholder(tf.float32, [None, None, None, 1], name='label')
...把它们放到我的神经网络:
tn_prediction0, tn_prediction1 = cnn.construct_stereo_img(t_im0, t_im1)
t_img = tf.subtract(tn_prediction0, tn_prediction1)
tn_logits = cnn.construct_nn2(t_img)
在范围火车我打印出来:
with tf.name_scope("Train"):
optimizer = tf.train.AdamOptimizer(FLAGS.learning_rate).minimize(cost_function)
tf.summary.image('logits', tn_logits, max_outputs=4)
tf.summary.image('label', t_label, max_outputs=4)
而让他们在会话中运行:
with tf.Session(config=tf.ConfigProto(gpu_options=tf.GPUOptions(per_process_gpu_memory_fraction=0.333))) as sess:
coord = tf.train.Coordinator()
threads = tf.train.start_queue_runners(sess=sess, coord=coord)
sess.run(init)
for epoch in range(FLAGS.training_epochs):
for img in images:
_, summary_str, costs = sess.run([optimizer, merged_summary_op, cost_function],
feed_dict={t_im0: img.l_img.eval(), t_im1: img.r_img.eval(),
t_label: img.mask.eval()})
现在,H ere出现了我的问题:我想用sess.run()
代替循环来不遍历所有图像。
目前它正在一个接一个地三张图像。如何同时拍摄多张照片,例如[4, ?, ?, 3]
。我试图使用tf.concat()
,但如果我执行img.l_img.eval()
发生错误,因为图像具有不同的高度和宽度。
我也完全开放重组整个项目。
在使用tf.image.resize_image_with_crop_or_pad()进行连接之前将所有图像填充到相同大小的情况如何? – RobR
我认为这对结果并不好 – j35t3r