2017-05-24 15 views
3

368x368サイズの画像の特徴をVGG事前学習モデルで抽出します。ドキュメントによると、VGGnetは224x224サイズの画像を受け入れます。 Keras VGGに可変サイズの入力を与える方法はありますか?Keras VGGnet事前調整モデル可変サイズ入力

# VGG Feature Extraction 
x_train = np.random.randint(0, 255, (100, 224, 224, 3)) 
base_model = VGG19(weights='imagenet') 
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output) 
block4_conv2_features = modelVGG.predict(x_train) 

編集コード(それは働く!)

# VGG Feature Extraction 
x_train = np.random.randint(0, 255, (100, 368, 368, 3)) 
base_model = VGG19(weights='imagenet', include_top=False) 
modelVGG = Model(inputs=base_model.input, outputs=base_model.get_layer('block4_conv2').output) 
block4_conv2_features = modelVGG.predict(x_train) 

答えて

3

入力サイズが完全に接続された(Dense)層のニューロンの数に影響を及ぼします。

は、ここに私のコードです。したがって、完全に接続されたレイヤーを独自に作成する必要があります。

include_top=FalseでVGG19に電話をかけ、完全に接続されたレイヤーを削除してから、自分で追加してください。参照のためthis codeをチェックしてください。

+0

素早くお答えいただき、ありがとうございます – mkocabas

関連する問題