我正在嘗試使用張量板來觀察卷積神經網絡的學習。我對tf.summary.merge_all函數做的很好,可以創建一個合併的摘要。但是,我想跟蹤培訓和測試數據的準確性和損失。這篇文章很有用:Logging training and validation loss in tensorboard。爲了使事情更容易處理,我想將我的摘要合併成兩個合併的摘要,一個用於訓練和一個用於驗證(最終我會添加更多的東西,比如圖像權重等)。我試圖遵循來自張力板tf.summary.merge的描述。我無法做到這一點,我無法找到任何有用的例子來幫助我理解我的錯在哪裏。無法在tensorboard中使用summary.merge進行單獨的培訓和評估摘要
with tf.name_scope('accuracy'):
correct_prediction = tf.equal(tf.argmax(y_logits, 1), tf.argmax(y, 1))
accuracy = tf.reduce_mean(tf.cast(correct_prediction, 'float'))
tf.summary.scalar('accuracy', accuracy)
tf.summary.scalar('train_accuracy', accuracy)
with tf.name_scope('Cost'):
cross_entropy = tf.reduce_mean(
tf.nn.softmax_cross_entropy_with_logits(logits=y_logits, labels=y))
opt = tf.train.AdamOptimizer()
optimizer = opt.minimize(cross_entropy)
grads = opt.compute_gradients(cross_entropy, [b_fc_loc2])
tf.summary.scalar('cost', cross_entropy)
tf.summary.scalar('train_cost', cross_entropy)
with tf.Session() as sess:
writer = tf.summary.FileWriter('./logs/mnistlogs/1f', sess.graph)
sess.run(tf.global_variables_initializer())
merged = tf.summary.merge([cost, accuracy])
這將導致以下錯誤:
InvalidArgumentError (see above for traceback): Could not parse one of the summary inputs [[Node: Merge/MergeSummary = MergeSummary[N=2, _device="/job:localhost/replica:0/task:0/cpu:0"](Merge/MergeSummary/inputs_0, Merge/MergeSummary/inputs_1)]]
我想知道爲什麼會這樣是不行的,我怎麼能找到解決的辦法,任何工作實施讚賞。
此:https://stackoverflow.com/questions/40722413/how-to-use-several-summary-collections-in-tensorflow 也是一個很好的方法,如果你想繪製兩個獨特的總結小組。 – Maikefer