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,並保存。

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