Skip to content

Fine tuning VGG16 #18

Description

@jroberayalas

Hi,

Just a quick question, I'm trying to fine tune the VGG16 as suggested in the notebook 2.4. However, I got an error: The shape of the input to "Flatten" is not fully defined (got (None, None, 512). Make sure to pass a complete "input_shape" or "batch_input_shape" argument to the first layer in your model.. Not sure if anyone can give me a hint on this. My code is shown below:

from keras.applications import VGG16

model = VGG16(include_top=False)
for layer in model.layers:
    layer.trainable = False

top_model = Sequential()
top_model.add(Flatten(input_shape=model.output_shape[1:]))
top_model.add(Dense(768, activation='sigmoid'))
top_model.add(Dropout(0.0))
top_model.add(Dense(768, activation='sigmoid'))
top_model.add(Dropout(0.0))
top_model.add(Dense(n_labels, activation='softmax'))

model.add(top_model)

train_model(model,
            (X_train_gte5, y_train_gte5),
            (X_test_gte5, y_test_gte5), nb_classes)

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions