当前位置: 首页 > news >正文

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

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

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

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]

http://www.lryc.cn/news/405053.html

相关文章:

  • 虚拟机固定配置IP
  • 【Pytorch实用教程】pytorch中random_split用法的详细介绍
  • 第二讲:NJ网络配置
  • pytorch中常见的模型3种组织方式 nn.Sequential(OrderedDict)
  • 达梦数据库DM8-索引篇
  • 【中项】系统集成项目管理工程师-第4章 信息系统架构-4.5技术架构
  • 随机梯度下降 (Stochastic Gradient Descent, SGD)
  • TDengine 3.3.2.0 发布:新增 UDT 及 Oracle、SQL Server 数据接入
  • Ubuntu 24.04 LTS 无法打开Chrome浏览器
  • linux中RocketMQ安装(单机版)及springboot中的使用
  • 亚信安全终端一体化解决方案入选应用创新典型案例
  • Django视图与URLs路由详解
  • 怎么关闭 Windows 安全中心,手动关闭 Windows Defender 教程
  • 洛谷看不了别人主页怎么办
  • 邮件安全篇:企业电子邮件安全涉及哪些方面?
  • 软件测试09 自动化测试技术(Selenium)
  • 记录解决springboot项目上传图片到本地,在html里不能回显的问题
  • C++ 中 const 关键字
  • 客梯自动监测识别摄像机
  • 为什么那么多人学习AI绘画?工资香啊!
  • 国产JS库(js-tool-big-box)7月度总结
  • c++ 高精度加法(只支持正整数)
  • python键盘操作工具:ctypes、pyautogui
  • 计算机网络发展历史
  • 记录安装android studio踩的坑 win7系统
  • Python图形编程-PyGame快速入门
  • 邦芒宝典:8种方法调整职场心态
  • 华为OD2024D卷机试题汇总,含D量50%+,按算法分类刷题,事半功倍
  • Unity UGUI 之 Graphic Raycaster
  • 类和对象——相关的零碎知识