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