J'essaie d'affiner Inceptionv3 pré-formé dans Keras pour un problème de prédiction multi-étiquettes (17).ValueError lors du réglage fin Inception_v3 dans Keras
Voici le code:
# create the base pre-trained model
base_model = InceptionV3(weights='imagenet', include_top=False)
# add a new top layer
x = base_model.output
predictions = Dense(17, activation='sigmoid')(x)
# this is the model we will train
model = Model(inputs=base_model.input, outputs=predictions)
# we need to recompile the model for these modifications to take effect
# we use SGD with a low learning rate
from keras.optimizers import SGD
model.compile(loss='binary_crossentropy', # We NEED binary here, since categorical_crossentropy l1 norms the output before calculating loss.
optimizer=SGD(lr=0.0001, momentum=0.9))
# Fit the model (Add history so that the history may be saved)
history = model.fit(x_train, y_train,
batch_size=128,
epochs=1,
verbose=1,
callbacks=callbacks_list,
validation_data=(x_valid, y_valid))
Mais je suis entré dans le message d'erreur suivant et avait du mal à déchiffrer ce qu'il dit:
ValueError: Error when checking target: expected dense_1 to have 4 dimensions, but got array with shape (1024, 17)
Il semble avoir quelque chose à voir avec ce qu'il doesn J'aime pas mon codage à chaud pour les étiquettes comme cible. Mais comment puis-je obtenir la cible 4 dimensions?
Il semble que https://stackoverflow.com/questions/41764041/fine-tuning-pretrained-model-in-keras pourrait avoir la réponse? –
Ou peut-être https://stackoverflow.com/questions/43386463/keras-vgg16-fine-tuning?rq=1 –