【发布时间】:2018-01-17 14:27:35
【问题描述】:
我想重写我的代码以可视化我的数据集中的所有标签,并查看结果以进行比较。
您可以在左侧看到标签图像,在右侧看到学习输出:
我所有的图片都有不同的形状,我用
阅读它们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)
在范围 Train 我打印它们:
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()})
现在,我的问题来了:我想用sess.run( ) 替换循环以不遍历所有图像。
它目前正在将一个图像一个接一个地馈送三倍。如何同时处理多个图像,例如[4, ?, ?, 3]。我尝试使用tf.concat(),但如果我执行img.l_img.eval(),则会出现错误,因为图像具有不同的高度和宽度。
我也完全愿意重组整个项目。
【问题讨论】:
-
在使用 tf.image.resize_image_with_crop_or_pad() 连接之前将所有图像填充到相同大小怎么样?
-
我觉得这样对结果不好
标签: machine-learning tensorflow computer-vision tensorboard