2016-10-19 3 views
2

bekommen Für die folgende CNNKeras Form falsch Ausgang

model = Sequential() 
model.add(Convolution2D(64, 3, 3, border_mode='same', input_shape=(3, 256, 256))) 
# now model.output_shape == (None, 64, 256, 256) 

# add a 3x3 convolution on top, with 32 output filters: 
model.add(Convolution2D(32, 3, 3, border_mode='same')) 
# now model.output_shape == (None, 32, 256, 256) 
print(model.summary()) 

Allerdings Modell Zusammenfassung gibt die folgende Ausgabe

____________________________________________________________________________________________________ 
Layer (type)      Output Shape   Param #  Connected to      
==================================================================================================== 
convolution2d_44 (Convolution2D) (None, 3, 256, 64) 147520  convolution2d_input_24[0][0]  
____________________________________________________________________________________________________ 
convolution2d_45 (Convolution2D) (None, 3, 256, 32) 18464  convolution2d_44[0][0]   
==================================================================================================== 
Total params: 165984 

Warum ich erhalte die gegebene Ausgabeform?

Antwort

5

Dies ist ein Problem, das durch die Einstellung input_shape verursacht wird. In Ihrer aktuellen Einstellung möchten Sie 256x256 mit 3 Kanälen eingeben. Allerdings denkt Keras, dass Sie 3x256 Bild mit 256 Kanälen geben. Es gibt mehrere Möglichkeiten, es zu korrigieren.

  • Option 1: Ändern der Reihenfolge in input_shape

  • Option 2: Geben Sie image_dim_ordering in Ihre Schichten

  • Option 3: die keras Konfigurationsdatei ändern, indem Sie 'tf' auf 'th' Wechsel in Ihrem ~/.keras/keras.json

+0

Danke. Das war sehr hilfreich. –

+0

in ~/.keras/keras.json, ändern Sie "image_dim_ordering": "tf" zu "image_dim_ordering": "th" – Yakku