解决 TensorFlow 错误:'NotImplementedError: Cannot convert a symbolic Tensor to a numpy array'
这个错误是因为在使用'np.asarray()'函数时,其中包含了TensorFlow的符号张量(Symbolic Tensor),而该函数无法将符号张量转换为NumPy数组。要解决这个问题,可以使用'K.eval()'函数将符号张量转换为NumPy数组,例如:
import keras.backend as K
x_array = K.eval(x).reshape((x.shape[0], -1))
其中,'K.eval()'函数将符号张量'x'转换为NumPy数组,然后再使用'reshape()'函数将数组的形状修改为指定的形状。
原文地址: https://www.cveoy.top/t/topic/jsaO 著作权归作者所有。请勿转载和采集!