When Multiplication : IndentationError: expected an indented block

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


please help me to solve

您必须缩进最后一行(以打印开头)。

这是解决方案,特别感谢@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