0nroth1
0nroth1

Reputation: 201

What Can I do to improve the 96% (f-score) in my CNN Keras?

I'm running a project with roughly 22000 images (11000 each class) with ResNet50 fine tuning. This is my code:

base_model = ResNet50(weights='imagenet', include_top=True, input_shape=(224,224,3))

head_model = base_model.get_layer("conv5_block1_1_conv").output
    
head_model = Dropout(0.75)(head_model)
head_model = Flatten()(head_model)
head_model = Dense(1, activation="sigmoid")(head_model)
model = Model(inputs=base_model.input, outputs=head_model)
model.summary()
for layer in base_model.layers:
    layer.trainable = False
    
adam = Adam(lr=0.001)
model.compile(optimizer= adam, loss='binary_crossentropy', metrics=['accuracy'])

train_datagen = ImageDataGenerator()
train_generator = train_datagen.flow_from_directory(TRAIN_DIR,
    target_size=(224, 224),
    batch_size=50,
    class_mode='binary')
model.fit_generator(train_generator, steps_per_epoch=100)

model.save("asd.h5")

With this model I reached 96 % of f-score. What method I can apply to improve its accuracy? I already tried include colormap as preprocessing and Include Dense layers.

Upvotes: 1

Views: 126

Answers (1)

Yoskutik
Yoskutik

Reputation: 2089

There're a lot of techniques:

  1. You can change the structure of model. Add or remove some layers (and not only Dense layers). Or use other pretrained model.
  2. Change the optimizer. For example, despite the Adam another popular optimizer is RMSprop. You can also try to tune optimizer's hyperparameters.
  3. Preprocess data. You can do zoom, shear and etc.

Upvotes: 1

Related Questions