Reputation: 39
I am trying to convert a Tensor to a numpy array. The tensor i have has a shape as below
LastDenseLayer.output.shape
TensorShape([None, 128])
When i am running the code as below,
with tf.Session() as sess:
LastLayer = LastDenseLayer.output.eval()
getting the below error
I am running Keras model and trying to get the values of a specific layer out of that.
Unable to understand that is wrong here.
Regards Sachin
Upvotes: 0
Views: 971
Reputation: 448
It's recommended to update your code to meet Tensorflow 2.0 requirements. As a quick solution you can use tf.compat.v1.Session()
instead of tf.Session()
:
with tf.compat.v1.Session() as sess:
LastLayer = LastDenseLayer.output.eval()
Upvotes: 0
Reputation: 19260
TensorFlow 2.x removed tf.Session
because eager execution is now a default. Please refer to the TensorFlow migration guide for more information.
Upvotes: 1