当前位置: 代码迷 >> 综合 >> ValueError: You cannot build your model by calling `build` if your layers do not support float type
  详细解决方案

ValueError: You cannot build your model by calling `build` if your layers do not support float type

热度:80   发布时间:2024-02-01 23:35:16.0

文章目录

  • 问题
  • 原因
  • 解决

问题

tensorflow 2.2 要build一个模型,代码如下:

model = GCN(UNITS) # 实例化一个模型
# out = model([x,a])
# print(out)
model.build(input_shape=(None,FEATURE)) # 指定模型的输入形状

出现错误提示:

ValueError: You cannot build your model by calling `build` if your layers do not support float type inputs. Instead, in order to instantiate and build your model, `call` your model on real tensor data (of the correct dtype).

原因

输入有两个,但build的时候只写了一个

解决

model = GCN(UNITS) # 实例化一个模型
# out = model([x,a])
# print(out)
model.build(input_shape=[(None,FEATURE),(None,FEATURE)]) # 指定模型的输入形状
  相关解决方案