我真的不明白为什么张量板没有显示我的网络图。我已经按照Tensorboard Website上的教程和网络上的其他内容,这些都不允许显示图表。
我正在嵌入与网络相关的代码部分。我试图删除所有其他部分,但我不想减少太多,否则它可能会造成混乱。它在图表部分显示的唯一内容是global_step
。
#tf.reset_default_graph()
# create a glboal step variable
global_step = tf.Variable(0, name='global_step', trainable=False)
with tf.Session() as sess:
# Writes Tensorboard summaries to disk
summary_writer = None
with tf.variable_scope(scope):
# Build the network
# Our input are 4 RGB frames of shape ?, ? each
X_pl = tf.placeholder(shape=[None, 50, 50, 4], dtype=tf.uint8, name="X")
# The TD target value
y_pl = tf.placeholder(shape=[None], dtype=tf.float32, name="y")
# Integer id of which action was selected
actions_pl = tf.placeholder(shape=[None], dtype=tf.int32, name="actions")
X = tf.to_float(X_pl) / 255.0
batch_size = tf.shape(X_pl)[0]
# three convolutional layers
with tf.name_scope('Convolutional_Layer_1') as scope:
conv1 = tf.contrib.layers.conv2d(X, 32, 8, 4, activation_fn=tf.nn.relu)
# other conv layers
# flattened layer
with tf.name_scope('Flattened_Layer') as scope:
flattened = tf.contrib.layers.flatten(conv3)
# fully connected layer
with tf.name_scope('Fully_Connected_Layer') as scope:
fc1 = tf.contrib.layers.fully_connected(flattened, 512)
predictions = tf.contrib.layers.fully_connected(fc1, len(VALID_ACTIONS))
# other stuff
# reduce input losses, return tensor with single element
with tf.name_scope('Loss') as scope:
loss = tf.reduce_mean(losses)
# optimizer parameters from original paper
with tf.name_scope('Optimization') as scope:
optimizer = tf.train.RMSPropOptimizer(0.00025, 0.99, 0.0, 1e-6)
train_op = optimizer.minimize(loss, global_step=tf.contrib.framework.get_global_step())
# summaries for Tensorboard
tf.summary.scalar("Loss", loss)
tf.summary.scalar("Max_Q_Value", tf.reduce_max(predictions))
tf.summary.histogram("Loss_Hist", losses)
tf.summary.histogram("Q_Values_Hist", predictions)
summaries = tf.summary.merge_all()
if summaries_dir:
summary_dir = os.path.join(summaries_dir, "summaries_{}".format(scope))
# create directory if does not exist
if not os.path.exists(summary_dir):
os.makedirs(summary_dir)
summary_writer = tf.summary.FileWriter(summary_dir, graph=sess.graph)
sess.run(tf.global_variables_initializer())
# other stuff not important
total_t = sess.run(tf.contrib.framework.get_global_step())
# other stuff not important
for i_episode in range(num_episodes):
# other stuff not important
# one step in the environment
for t in itertools.count():
# other stuff not important
# add epsilon to Tensorboard
episode_summary = tf.Summary()
episode_summary.value.add(simple_value=epsilon, tag="epsilon")
q_estimator.summary_writer.add_summary(episode_summary, total_t)
# other stuff not important
break
# add summaries to tensorboard
episode_summary = tf.Summary()
episode_summary.value.add(simple_value=stats.episode_rewards[i_episode], node_name="episode_reward", tag="Episode_Reward")
episode_summary.value.add(simple_value=stats.episode_lengths[i_episode], node_name="episode_length", tag="Episode_Length")
q_estimator.summary_writer.add_summary(episode_summary, total_t)
q_estimator.summary_writer.flush()
我刚开始使用Tensorboard,但我能够按照相同的过程显示其他图形。我不明白现在有什么不对。
提前致谢。