tensorflow-gpu numpy AttributeError Tensor object has no attribute numpy
This error occurs when you try to use the numpy() method on a TensorFlow Tensor object. The numpy() method is used to convert a TensorFlow tensor to a NumPy array, but it is only available on TensorFlow versions 1.15 and higher.
To fix this error, you can either upgrade your TensorFlow version or use alternative methods to convert your tensor to a NumPy array. One way to do this is to use the eval() method, which evaluates the tensor and returns a NumPy array. For example:
import tensorflow as tf
# create a TensorFlow tensor
x = tf.constant([1, 2, 3])
# evaluate the tensor and convert it to a NumPy array
x_np = x.eval(session=tf.compat.v1.Session())
print(x_np)
This should output [1 2 3] as a NumPy array.
原文地址: https://www.cveoy.top/t/topic/bJJf 著作权归作者所有。请勿转载和采集!