这个错误提示说明输入给某个层的不是一个符号张量,而是一个numpy数组。解决这个问题需要将输入转换为符号张量。可以使用tf.convert_to_tensor()函数将numpy数组转换为符号张量。例如:

import tensorflow as tf
import numpy as np

# 定义一个层
layer = tf.keras.layers.Dense(units=10)

# 定义一个输入numpy数组
input_np = np.random.rand(100, 2)

# 将输入numpy数组转换为符号张量
input_tensor = tf.convert_to_tensor(input_np)

# 将符号张量输入到层中
output = layer(input_tensor)
解决as called with an input that isnt a symbolic tensor Received type class numpyndarray Full input array11339139 54479957 12107415 60850334 33124623 8824976 4810546 10

原文地址: https://www.cveoy.top/t/topic/bKz4 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录