简体   繁体   中英

When Multiplication : IndentationError: expected an indented block

When i am trying to multiplication with two number getting below error in 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

You must indent the last line (starting with print).

This is solution and Special Thanks To @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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM