Issue
I downloaded this code from GitHub.
predicted_id = tf.multinomial(tf.exp(predictions), num_samples=1)[0][0].numpy()
But I get an error that says:
AttributeError: 'Tensor' object has no attribute 'numpy'
What is wrong, and how do I fix it?
Solution
I suspect the place where you copied the code from had eager execution enabled, i.e. had invoked tf.enable_eager_execution()
at the start of the program.
You could do the same.
UPDATE: Note that eager execution is enabled by default in TensorFlow 2.0. So the answer above applies only to TensorFlow 1.x
Answered By - ash
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.