Tensorboard SyntaxError:语法无效

2024-06-20

当我尝试制作张量板时,出现语法错误。尽管开源代码我还是无法理解。我尝试搜索张量板的代码,但不清楚。

即使我不擅长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中定义变量,例如

日志路径 = /tmp/logs/1

然后像这样定义你的作家

作家 = tf.summary.FileWriter(日志路径,graph=tf.get_default_graph())

然后在命令提示符下运行命令

张量板--logdir =/tmp/日志/1

本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

Tensorboard SyntaxError:语法无效 的相关文章

随机推荐