我已经实现了以下Tensorboard插件,但对Tensorboard的假设工具没有任何想法。请参见以下代码:
with tf.Session() as sess:
sess.run(tf.global_variables_initializer())
config = projector.ProjectorConfig()
writer = tf.summary.FileWriter("write",sess.graph)
merged = tf.summary.merge_all()
beholder = Beholder(writer.get_logdir())
for iteration in range(int(n_epochs*train_set_size/batch_size)):
x_batch, y_batch = get_next_batch(batch_size) # fetch the next training batch
sess.run([training_op,outputs,stacked_outputs], feed_dict={X: x_batch, y: y_batch})
if iteration % int(1*train_set_size/batch_size) == 0:
run_options = tf.RunOptions(trace_level=tf.RunOptions.FULL_TRACE)
run_metadata = tf.RunMetadata()
mse_train = loss.eval(feed_dict={X: x_train, y: y_train})
mse_valid = loss.eval(feed_dict={X: x_valid, y: y_valid})
mse_test = loss.eval (feed_dict={X: x_test, y: y_test})
out_train,merge , l= sess.run([outputs,merged,loss], feed_dict={X: x_train, y: y_train},run_metadata=run_metadata
,options=run_options)
beholder.update(session=sess,arrays=out_train)
writer.add_run_metadata(run_metadata, 'step%d' % iteration)
writer.add_summary(merge, iteration)
print('%.2f epochs: MSE train/valid/test = %.10f/%.10f/%.10f'%(
iteration*batch_size/train_set_size, mse_train, mse_valid,mse_test))
try:
save_path = saver.save(sess, "write\\model"+str(iteration)+".ckpt")
except Exception as e:
print(e)
if not os.path.exists("write\\"):
os.makedirs("write\\")
save_path = saver.save(sess, "write\\model"+str(iteration)+".ckpt")
该图显示了实现:
但是我看不到如何在Tensorboard可视化中实现What-If-Tool插件。
请帮助我实施它。还有其他需要澄清的问题,我会提供。