我正在嘗試使用tensorflow的SummaryWriter,但它似乎沒有將事件,圖像或直方圖寫入文件。但是它會將圖形寫入文件(我可以在張力板中看到),至少表明tensorboard和SummaryWriter知道我的logdir在哪裏。SummaryWriter不會將摘要寫入文件
這是我的(簡化的)碼,通過省略代碼塊打碎:
sess = tf.Session()
W_conv1 = tf.Variable(tf.truncated_normal([5,5,3, hidden1_size], stddev = 0.01), name = 'W_conv1')
b_conv1 = tf.Variable(tf.constant(0.01, shape=[hidden1_size]), name = 'b_conv1')
#to visualize the weights of the first layer...
sum2 = tf.image_summary('first layer weights', tf.transpose(W_conv1, perm = [3, 0, 1, 2]), max_images = 16)
h_conv1 = tf.nn.relu(b_conv1 + conv(x, W_conv1))
#to visualize how many dead relu's we have
sum1 = tf.scalar_summary('conv1', tf.nn.zero_fraction(h_conv1))
....更多層
softmax = {}
cross_entropy = tf.Variable(0.0)
softmax[0] = tf.nn.softmax(fc_out)
cross_entropy += -tf.reduce_sum(y_*tf.log(softmax[0]))
.... Reccurrent部分
sum3 = tf.histogram_summary('cross entropy', cross_entropy)
lr = tf.Variable(tf.constant(1e-3))
lr_change = tf.assign(lr, tf.mul(.1, lr))
train_step = tf.train.AdamOptimizer(lr).minimize(cross_entropy)
merged=tf.merge_all_summaries()
writer = tf.train.SummaryWriter("./logs", sess.graph_def, flush_secs = 5)
sess.run(tf.initialize_all_variables())
....然後訓練碼:
for i in range(train_iter):
batch_i = np.random.randint(0, len(X_t), [batch_size])
X_batch = X_t[batch_i]
y_batch = y_t[batch_i]
summary_str, _, loss = sess.run([merged, train_step, cross_entropy], feed_dict = {x: X_batch, y_: y_batch})
writer.add_summary(summary_str, i)
writer.flush()
saver.save(sess, 'RNN_model.ckpt', global_step = i)
然後當我加載tensorboard,並期待在事件選項卡上,我看到了以下錯誤:
No scalar summary tags were found.
Maybe data hasn't loaded yet, or maybe you need to add some >tf.scalar_summary ops to your graph, and serialize them using the >tf.training.summary_io.SummaryWriter.
我增加了writer.flush()語句,因爲在GitHub上的兩個堆疊交換搜索後,這是一個常見的建議。問題沒有解決。
在我的日誌文件中,只寫入了graph_def,在訓練期間沒有其他文件被寫入。
我在mac 0SX el-capitan上使用tensorflow'0.7.1'。
謝謝!
你TensorBoard /簡要用法看起來是正確的。 您確定只有graph_def正在寫入事件文件嗎?你可以上傳嗎?然後我可以檢查是否有直方圖摘要等寫入,並確定問題是否與TensorBoard或事件編寫代碼相關。 – dandelion
當然,非常感謝! https://drive.google.com/file/d/0B5GqMWTiEZZAR2gyU3RiWDFzMVE/view?usp=sharing ps.s.我認爲這只是圖表BC。它只在定義網絡時寫入一次文件,但從不在培訓期間。 –
我從[openai/InfoGAN](https://github.com/openai/InfoGAN#running-experiment)運行示例Docker實驗注意到了相同的情況。 它只在開始時輸出日誌,但在訓練後不輸出。 – NHDaly