基于TensorFlow的级联CNN多输入多输出模型数据加载拼接报错求助
级联模型训练时拼接层通道不兼容问题
我尝试实现某论文提出的级联模型,模型整体架构如下:
数据分为两个子集:
- 道路子集:(img, mask_road)
- 中心线子集:(同一img, mask_centerline)
我使用tf.data.Dataset API构建数据加载流水线,完成数据读取、解码并转换为[0,1]范围的张量。为训练模型,将输入数据集进行zip操作:
zip_train = tf.data.Dataset.zip((dataset_train,center_train)) zip_valid = tf.data.Dataset.zip((dataset_val,center_val)) zip_test = tf.data.Dataset.zip((dataset_test,center_test))
根据模型图,中心线提取网络(网络2)的输入为道路检测网络(网络1)的最后一层特征图及对应子集,因此我在模型定义中对二者进行拼接。运行代码时出现拼接层通道不兼容错误,报错信息如下:
history = model.fit( zip_train, epochs=epochs, steps_per_epoch=steps, validation_data=zip_valid, callbacks=callbacks ) Input 0 of layer "d1_11_conv" is incompatible with the layer: expected axis -1 of input shape to have value 67, but received input with shape (None, 512, 512, 65) Call arguments received by layer 'model_12' (type Functional): • inputs=('tf.Tensor(shape=(None, 512, 512, 3), dtype=float32)', 'tf.Tensor(shape=(None, 512, 512, 1), dtype=float32)') • training=True • mask=None
请问该如何解决?可复现代码包含级联模型定义及数据加载流水线。
内容的提问来源于stack exchange,提问作者grc
相关产品推荐
相关产品推荐

