当我尝试制作张量板时,出现语法错误。尽管开源代码我还是无法理解。我尝试搜索张量板的代码,但不清楚。
即使我不擅长Python。我这样写路径,C:\\Users\\jh902\\Documents\\.logs
因为我使用的是Windows 10,但我不确定。 (我使用了双反斜杠,但在这个监视器中它看起来像一个斜杠)。
如果我这样编码,
tensorboard --logdir="C:\Users\\jh902\\Documents\\.logs"
this error message comes out
File "<ipython-input-32-4b130bd6177b>", line 1
tensorboard --logdir="C:\Users\\jh902\\Documents\\.logs"
^
SyntaxError: can't assign to operator
有什么问题吗?
# cost/loss function
cost = tf.reduce_mean(tf.square(hypothesis - Y))
# Minimize/Optimizer
optimizer = tf.train.AdamOptimizer(learning_rate=1e-5)
train = optimizer.minimize(cost)
# Launch the graph in a session.
sess = tf.Session()
w2_hist=tf.summary.histogram("weight2",W2)
cost_summ=tf.summary.scalar("cost",cost)
summary=tf.summary.merge_all()
#Create Summary writer
writer=tf.summary.FileWriter("C:\\Users\\jh902\\Documents\\.logs")
writer.add_graph(sess.graph)
# Initializes global variables in the graph.
sess.run(tf.global_variables_initializer())
# Fit the Line with new training data
for step in range(1001):
s, cost_val, hy_val, _ = sess.run([summary, cost, hypothesis, train], feed_dict={X: x_data, Y: y_data})
writer.add_summary(s, global_step=step)
if step % 100 == 0:
print(step, "Cost: ", cost_val, "Prediction: ", hy_val)
tensorboard --logdir=C:\\Users\\jh902\\Documents\\.logs
File "<ipython-input-29-82d09538d544>", line 1
tensorboard --logdir=C:\\Users\\jh902\\Documents\\.logs
^
SyntaxError: invalid syntax
最佳答案
尝试在 Python 中定义变量,例如
logs_path =/tmp/logs/1
然后像这样定义你的作家
writer = tf.summary.FileWriter(logs_path,graph=tf.get_default_graph())
然后在命令提示符下运行命令
tensorboard --logdir = /tmp/logs/1
关于python - Tensorboard语法错误: invalid syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44038584/