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]
相关推荐
山烛14 分钟前
OpenCV图像形态学操作
图像处理·人工智能·python·opencv·计算机视觉·图像形态学
Q_Q51100828522 分钟前
python的校园研招网系统
开发语言·spring boot·python·django·flask·node.js·php
大志若愚YYZ1 小时前
兴趣爱好——虾哥开源小智AI机器人搭建(丐版—最低成本)ESP32开发板 MicroPython V1.0.0 Rev1
ai·小智
AI_RSER1 小时前
遥感&机器学习入门实战教程|Sklearn 案例④ :多分类器对比(SVM / RF / kNN / Logistic...)
python·算法·机器学习·支持向量机·分类·sklearn
于越海2 小时前
Python工程师向项目管理转型的深度分析与学习道路规划
笔记·python·学习
二闹2 小时前
discard和remove的那些事儿
python
大志说编程2 小时前
LangChain框架入门18: 十分钟带你搞定LLM工具调用
python·langchain·ai编程
十二测试录3 小时前
AI 驱动研发变革:技术突破与行业落地实践全景
人工智能·ai·aigc
AI视觉网奇4 小时前
麒麟系统播放图片 速度比较
开发语言·python·pygame
言之。4 小时前
Django REST框架核心:GenericAPIView详解
数据库·python·django