2016-09-03 21 views
0

を使用して、簡単な回帰と形状の寸法誤差を取得します。ネットワーク(X_test)の入力は100画像であり、出力はさらに100です。問題はシェイプエラーが発生していることです。私は別のネットワークアーキテクチャ、アクティベーションを行っています...エラーはまだ存在します。は、私がKeras上の単純な回帰ネットワークを訓練しようとしていますKeras

ここで私は私のコードを配置します。私は、スクリプトを実行すると

M=32 

input_layer   = Input(shape=(3, 32, 32), name="input") 

sc1_conv1   = Convolution2D(96, 3, 3, activation='relu', init='glorot_uniform', subsample=(2,2), border_mode='valid')(input_layer) 

sc1_maxpool1  = MaxPooling2D(pool_size=(2,2))(sc1_conv1) 

sc1_fire2_squeeze = Convolution2D(M, 1, 1, activation='relu', init='glorot_uniform', border_mode='same')(sc1_maxpool1) 
sc1_fire2_expand1 = Convolution2D(M*4, 1, 1, activation='relu', init='glorot_uniform', border_mode='same')(sc1_fire2_squeeze) 
sc1_fire2_expand2 = Convolution2D(M*4, 3, 3, activation='relu', init='glorot_uniform', border_mode='same')(sc1_fire2_squeeze) 
sc1_merge1   = merge(inputs=[sc1_fire2_expand1, sc1_fire2_expand2], mode="concat", concat_axis=1) 
sc1_fire2   = Activation("linear")(sc1_merge1) 

model    = Model(input=input_layer, output=sc1_fire2) 
model.compile(loss='mse', optimizer='rmsprop') 
model.fit(X_train, y_train, nb_epoch=10, batch_size=64) 

、私は次のエラーを取得する:

Exception: Error when checking model target: expected activation_9 to have shape (None, 256, 7, 7) but got array with shape (100, 3, 32, 32) 

X_trainとy_train形状は以下のとおりです。

X_train.shape 
Out[13]: (100, 3, 32, 32) 
y_train.shape 
Out[14]: (100, 3, 32, 32) 

ケラスで初めて回帰をしていて、何が間違っているのか分かりません。

ありがとうございました!

答えて

0

モデルの出力形状がある(なし、256、7、7)。それはy_trainの形と一致するはずです。シェイプ(None、3、32、32)を取得するには、アップサンプリングレイヤを追加することによって、アーキテクチャを変更する必要があります。たとえば、https://blog.keras.io/building-autoencoders-in-keras.htmlを参照してください。

+0

あなたが正しい、解決策は、アップサンプリングを使用して、私のアーキテクチャを変更するとy_trainの形状に合わせてレイヤーを再形成されました。 :) – sergi2k

関連する問題