4
import tensorflow as tf
a=tf.constant(2)
b=tf.constant(3)
c=a+b
sess=tf.Session(c)
sess.run()

I got the error message module 'tensorflow' has no attribute 'Session'

2

2 Answers 2

5

From the official doc try the following:

# Build a graph.
a = tf.constant(5.0)
b = tf.constant(6.0)
c = a * b

# Launch the graph in a session.
sess = tf.compat.v1.Session()

# Evaluate the tensor `c`.
print(sess.run(c))
Sign up to request clarification or add additional context in comments.

Comments

1

Try this way:

with tf.compat.v1.Session() as sess:

  a = tf.constant(5.0)
  b = tf.constant(6.0)
  c = tf.multiply(a, b)

  result = sess.run(c)
  print(result)

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.