NotImplementedError Cannot convert a symbolic Tensor lstmstrided_slice0 to a numpy array
This error occurs when you try to convert a symbolic tensor to a numpy array. A symbolic tensor is a tensor that is defined but not yet evaluated.
To resolve this error, you need to first evaluate the tensor before converting it to a numpy array.
Here are a few ways to do that:
- Use the
.eval()method to evaluate the tensor:
import tensorflow as tf
sess = tf.Session()
tensor = tf.constant([1, 2, 3])
numpy_array = tensor.eval(session=sess)
- Use the
tf.Session().run()method to evaluate the tensor:
import tensorflow as tf
sess = tf.Session()
tensor = tf.constant([1, 2, 3])
numpy_array = sess.run(tensor)
- Use the
tf.keras.backend.eval()method to evaluate the tensor:
import tensorflow as tf
tensor = tf.constant([1, 2, 3])
numpy_array = tf.keras.backend.eval(tensor)
原文地址: http://www.cveoy.top/t/topic/ZMQ 著作权归作者所有。请勿转载和采集!