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]

相关推荐

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-07-19 21:28:02       67 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-07-19 21:28:02       71 阅读
  3. 在Django里面运行非项目文件

    2024-07-19 21:28:02       58 阅读
  4. Python语言-面向对象

    2024-07-19 21:28:02       69 阅读

热门阅读

  1. k8s二次开发-kubebuiler一键式生成deployment,svc,ingress

    2024-07-19 21:28:02       14 阅读
  2. k8s系列问题:[ERROR Port-10250]: Port 10250 is in use

    2024-07-19 21:28:02       14 阅读
  3. AI驱动的漏洞检测

    2024-07-19 21:28:02       20 阅读
  4. 一个简单的springboot应用搭建过程

    2024-07-19 21:28:02       17 阅读
  5. POST请求查询参数神奇失效的一次神奇bug之旅

    2024-07-19 21:28:02       16 阅读
  6. 智能家居和智能家电有什么区别?

    2024-07-19 21:28:02       21 阅读
  7. Leetcode 9. 回文数

    2024-07-19 21:28:02       21 阅读
  8. final字段总结

    2024-07-19 21:28:02       15 阅读
  9. antd drawer extra中按钮点击事件获取子组件的数据

    2024-07-19 21:28:02       18 阅读