Closed jiangzihanict closed 5 years ago
@jiangzihanict, If you want to perform a classification task, the include_top
should be True
.
@taehoonlee My image size is (64,64). if the include_top
is true
, the image size only to be (224,224)
@jiangzihanict, It is possible to call model = keras.applications.resnet50.ResNet50(include_top=True, weights=None, input_shape=(64, 64, 3), classes=2)
. Please try pip install -U keras keras-applications
.
I am using latest keras and keras-application to train a resnet50 model, but found following error. I have been google for a long time but haven't found a solution.
The related code:
input_shape=(64,64,3)
model = keras.applications.resnet50.ResNet50(include_top=False, weights=None, input_shape=input_shape, classes=2)
train_gen = ImageDataGenerator(preprocessing_function=keras.applications.resnet50.preprocess_input)
train_iter = train_gen.flow(tr_x, tr_y, batch_size=args.batch_size)
val_gen = ImageDataGenerator(preprocessing_function=keras.applications.resnet50.preprocess_input)
val_iter = val_gen.flow(val_x, val_y,batch_size=args.val_batch_size)
model.fit_generator(train_iter,
steps_per_epoch=train_batches // hvd.size(),
callbacks=callbacks,
epochs=args.epochs,
verbose=1,
workers=4,
validation_data=val_iter,
validation_steps=3 * val_batches // hvd.size())
Error: ValueError: Error when checking target: expected activation_49 to have 4 dimensions, but got array with shape (32, 2) I am using latest keras and keras-application to train a resnet50 model, but found following error. I have been google for a long time but haven't found a solution.
The related code: input_shape=(64,64,3) model = keras.applications.resnet50.ResNet50(include_top=False, weights=None, input_shape=input_shape, classes=2) train_gen = ImageDataGenerator(preprocessing_function=keras.applications.resnet50.preprocess_input) train_iter = train_gen.flow(tr_x, tr_y, batch_size=args.batch_size) val_gen = ImageDataGenerator(preprocessing_function=keras.applications.resnet50.preprocess_input) val_iter = val_gen.flow(val_x, val_y,batch_size=args.val_batch_size) model.fit_generator(train_iter, steps_per_epoch=train_batches // hvd.size(), callbacks=callbacks, epochs=args.epochs, verbose=1, workers=4, validation_data=val_iter, validation_steps=3 * val_batches // hvd.size())
Error: ValueError: Error when checking target: expected activation_49 to have 4 dimensions, but got array with shape (32, 2)
Do I need to resize the image shape from (64,64) to (224,224)?
Thanks!