ValueError: A `Concatenate` layer requires inputs with matching shapes except for the concat axis.

在使用keras在调试densnet时出现上述问题:

x = concatenate([x, cb], axis=-1)

原因是,图像通道数位置的不同造成的,keras基于tensorflow开发的而tensorflow的图像格式是[batchsize,H,W,channels],在执行vi ~/.keras/keras.json时发现:

  1 {
  2     "floatx": "float32",
  3     "epsilon": 1e-07,
  4     "backend": "tensorflow",
  5     "image_data_format": "channels_first"
  6 }
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                                                                               
~                             

修改image_data_format,将"channels_first改为channel_last,并保存。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章