tensorflow keras Model.fit returning: ValueError: Unrecognized data type

题意:TensorFlow Keras 的 Model.fit 方法返回了一个 ValueError,提示数据类型无法识别

问题背景:

I'm trying to train a keras model with 2 inputs: an image part that's a tf.data.Dataset and a nor mal part represented by a pd.DataFrame

python 复制代码
from tensorflow.keras.optimizers import Adam
opt = Adam(learning_rate=1e-3, decay=1e-3 / 200)

model.compile(loss="mean_absolute_percentage_error", optimizer=opt)

model.fit(
    x=[df.loc[:, df.columns != 'target'], ds.batch(8)], y=df["target"],
    epochs=200)

I was trying to fit the model but I get ValueError

python 复制代码
ValueError: Unrecognized data type: x=[...][401059 rows x 52 columns]
, <_BatchDataset element_spec=(TensorSpec(shape=(None, 32, 256, 256, 3), 
dtype=tf.float32, name=None), 
TensorSpec(shape=(None, 32, 256, 256, 3), dtype=tf.float32, name=None))>] (of type <class 'list'>)

问题解决:

the problem was an error in tensoflow zipping and reformating dataset helped

python 复制代码
def post_zip_process(example1, example2):
    reshaped_input = tf.transpose(example1[0], [0, 1, 2 ,-1])
    reshaped_input = reshaped_input[0, :, :, :]
    print(reshaped_input.shape)
    return (reshaped_input, example2[0]), example1[1]
相关推荐
HarmonLTS9 分钟前
Python Socket网络通信详解
服务器·python·网络安全
天上掉下个牛霸天20 分钟前
2025年十大技术趋势前瞻
人工智能·ai
郝学胜-神的一滴20 分钟前
Python数据封装与私有属性:保护你的数据安全
linux·服务器·开发语言·python·程序人生
智航GIS28 分钟前
11.7 使用Pandas 模块中describe()、groupby()进行简单分析
python·pandas
Pyeako32 分钟前
机器学习--矿物数据清洗(六种填充方法)
人工智能·python·随机森林·机器学习·pycharm·线性回归·数据清洗
ScilogyHunter1 小时前
SCons:Python驱动的智能构建系统
python·构建系统·scons
luoluoal1 小时前
基于python的基于深度学习的车俩特征分析系(源码+文档)
python·mysql·django·毕业设计·源码
轻竹办公PPT2 小时前
2026 年 AI 办公趋势:AI 生成 PPT 工具谁在领先
人工智能·python
Kingairy2 小时前
Python面试高频题
java·python·面试