I have following tensor object, which is outpur of a=model.layers[3].output
this code
a = <tf.Tensor 'dense_20/Softmax:0' shape=(None, 3) dtype=float32>
How to get values from above tensor object. I have tried print(a.numpy())
and getting following error:
AttributeError: 'Tensor' object has no attribute 'numpy'
I have also tried eval(a)
method, and getting same above error.
when using a.eval(), getting following error:
ValueError: Cannot evaluate tensor using `eval()`: No default session is registered. Use `with sess.as_default()` or pass an explicit session to `eval(session=sess)`
I have also tried following:
with tf.compat.v1.Session() as sess:
a=model.layers[3].output
print(sess.run(a))
sess.close()
and getting following error:
RuntimeError: The Session graph is empty. Add operations to the graph before calling run().
I have tried many things from here, but not getting answer.
I am working on google colab, tensorflow=2.2.0, keras=2.3.1