I have a ResNet model that is trained on 64x64 images. I would like to do transfer learning with new dataset that contains 200x200 images.
I am loading the model like:
`
model = ResNet50(include_top=False, weights=None, input_shape=(64,64,3))
model.load_weights("a trained model weights on 64x64")
model.layers.pop()
for layer in model.layers:
layer.trainable = False
x = model.output
x = MaxPooling2D((2,2), strides=(2,2), padding='same')(x)
x = Flatten(name='flatten')(x)
x = Dropout(0.2)(x)
x = Dense(512, activation='relu')(x)
predictions = Dense(101, activation='softmax', name='predictions')(x)
hist = top_model.fit_generator(generator=train_set,
epochs=EPOCHS,
steps_per_epoch = STEPS_PER_EPOCH,
validation_data=val_set,
validation_steps = VALIDATION_STEPS,
verbose=1,
callbacks=callbacks)
`
I would like to do transfer learning based with images of 200x200 pixels. I am very new to this, how can I modify?
is there a way to modify the model input shape? and do I. need to do something with spatial size?
And which optimizer is recommended? Adam or SGD?
`
I have a ResNet model that is trained on 64x64 images. I would like to do transfer learning with new dataset that contains 200x200 images.
I am loading the model like:
` model = ResNet50(include_top=False, weights=None, input_shape=(64,64,3)) model.load_weights("a trained model weights on 64x64")
model.layers.pop() for layer in model.layers: layer.trainable = False
x = model.output x = MaxPooling2D((2,2), strides=(2,2), padding='same')(x) x = Flatten(name='flatten')(x) x = Dropout(0.2)(x) x = Dense(512, activation='relu')(x) predictions = Dense(101, activation='softmax', name='predictions')(x)
top_model = Model(inputs=model.input, outputs=predictions)
top_model.compile(loss='categorical_crossentropy', optimizer=adam, metrics=[accuracy])
EPOCHS = 100 BATCH_SIZE = 32 STEPS_PER_EPOCH = 4424 // BATCH_SIZE VALIDATION_STEPS = 466 // BATCH_SIZE
callbacks = [LearningRateScheduler(schedule=Schedule(EPOCHS, initial_lr=lr_rate)), ModelCheckpoint(str(output_dir) + "/weights.{epoch:03d}-{val_loss:.3f}-{val_age_mae:.3f}.hdf5", monitor="val_age_mae", verbose=1, save_best_only=False, mode="min") ]
hist = top_model.fit_generator(generator=train_set, epochs=EPOCHS, steps_per_epoch = STEPS_PER_EPOCH, validation_data=val_set, validation_steps = VALIDATION_STEPS, verbose=1, callbacks=callbacks) ` I would like to do transfer learning based with images of 200x200 pixels. I am very new to this, how can I modify?
is there a way to modify the model input shape? and do I. need to do something with spatial size?
And which optimizer is recommended? Adam or SGD? `
res5c_branch2a (Conv2D) (None, 2, 2, 512) 1049088 activation_46[0][0]
bn5c_branch2a (BatchNormalizati (None, 2, 2, 512) 2048 res5c_branch2a[0][0]
activation_47 (Activation) (None, 2, 2, 512) 0 bn5c_branch2a[0][0]
res5c_branch2b (Conv2D) (None, 2, 2, 512) 2359808 activation_47[0][0]
bn5c_branch2b (BatchNormalizati (None, 2, 2, 512) 2048 res5c_branch2b[0][0]
activation_48 (Activation) (None, 2, 2, 512) 0 bn5c_branch2b[0][0]
res5c_branch2c (Conv2D) (None, 2, 2, 2048) 1050624 activation_48[0][0]
bn5c_branch2c (BatchNormalizati (None, 2, 2, 2048) 8192 res5c_branch2c[0][0]
add_16 (Add) (None, 2, 2, 2048) 0 bn5c_branch2c[0][0]
activation_46[0][0]
activation_49 (Activation) (None, 2, 2, 2048) 0 add_16[0][0]
pred_age (Dense) (None, 2, 2, 101) 206848 activation_49[0][0]
Total params: 23,794,560 Trainable params: 23,741,440 Non-trainable params: 53,120
`
Getting the following error
ValueError: Error when checking input: expected input_1 to have shape (64, 64, 3) but got array with shape (128, 128, 3)