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]
相关推荐
魏杨杨22 分钟前
一个程序员眼中的 AI 核心概念,讲透 LLM 、Agent 、MCP 、Skill 、RAG...
ai·.net·agent·claude code
RyFit1 小时前
SpringAI 常见问题及解决方案大全
java·ai
前端若水1 小时前
会话管理:创建、切换、删除对话历史
前端·人工智能·python·react.js
元拓数智1 小时前
智能分析落地卡壳?先补好「数据关系+语义治理」这层技术基建
大数据·分布式·ai·spark·数据关系·语义治理
企学宝1 小时前
企学宝5月专题课程丨《OpenClaw AI 智能体实战营:从零基础部署到全场景自动化落地》
人工智能·ai·企业培训
涛声依旧-底层原理研究所2 小时前
残差连接与层归一化通俗易懂的详解
人工智能·python·神经网络·transformer
csdn_aspnet2 小时前
Python 算法快闪 LeetCode 编号 70 - 爬楼梯
python·算法·leetcode·职场和发展
fantasy_arch3 小时前
pytorch人脸匹配模型
人工智能·pytorch·python
熊猫_豆豆3 小时前
广义相对论水星近日点进动完整详细数学推导
python·天体·广义相对论
web3.08889993 小时前
1688 图搜接口(item_search_img / 拍立淘) 接入方法
开发语言·python