[英]When Multiplication : IndentationError: expected an indented block
当我尝试将两个数字相乘时,jupyter 中的错误低于错误。
import tensorflow as tf
tf.executing_eagerly()
x = tf.constant(2)
y = tf.constant(3)
multi = x*y
with tf.Session() as sess:
print(sess.run(multi))
## error
File "<ipython-input-35-755ab78de6c6>", line 5
print(sess.run(multi))
^
IndentationError: expected an indented block
您必须缩进最后一行(以 print 开头)。
这是解决方案,特别感谢@Ben2209
tf.__version__
tf.executing_eagerly()
with tf.compat.v1.Session() as sess:
a = tf.constant(2)
b = tf.constant(5)
c = a*b
print(sess.run(c))
** Output **
10
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.