如何在TensorBoard中查看多张图片?

我想重写我的代码,以便可视化数据集中所有的标签,并查看结果以进行比较。

你可以在左侧看到标签图片,在右侧看到学习后的输出:

tensorboard

我所有的图片形状都不同,我用以下方式读取它们:

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()})

现在,我的难题是:我想用sess.run( )替换循环,不再遍历所有图片。

目前它是一次处理一个图片三元组。如何同时处理多张图片,例如[4, ?, ?, 3]。我尝试使用tf.concat(),但在执行img.l_img.eval()时,由于图片的高度和宽度不同,会发生错误。

我也很乐意重构整个项目。


回答:

除非图片/批次具有相同大小,否则无法增加图片的第一维度[1, h, w, rgb]。

调整大小/裁剪会导致不良结果。

简而言之,这是不可能的。

Related Posts

L1-L2正则化的不同系数

我想对网络的权重同时应用L1和L2正则化。然而,我找不…

使用scikit-learn的无监督方法将列表分类成不同组别,有没有办法?

我有一系列实例,每个实例都有一份列表,代表它所遵循的不…

f1_score metric in lightgbm

我想使用自定义指标f1_score来训练一个lgb模型…

通过相关系数矩阵进行特征选择

我在测试不同的算法时,如逻辑回归、高斯朴素贝叶斯、随机…

可以将机器学习库用于流式输入和输出吗?

已关闭。此问题需要更加聚焦。目前不接受回答。 想要改进…

在TensorFlow中,queue.dequeue_up_to()方法的用途是什么?

我对这个方法感到非常困惑,特别是当我发现这个令人费解的…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注