I'm starting to get into the world of neural networks on the run. We are trying to find a good fit for the following dataset: https://www.kaggle.com/tanlikesmath/diabetic-retinopathy-resized (The classic Diabetic Retinopathy)
I'm really stuck at the moment as no matter what I do I never get a CCR higher than 0.75. I have tried several types of Data Augmentation and to modify the VGG16 network (which is the one we have been asked to do this practice with). Sometimes during the iterations, I watch it go up but at the end, when the epoch is over it ends up again between 0.72 and 0.75.
I'm pretty new to this and it's obvious I'm doing things wrong but I don't know what yet.
train_datagen = ImageDataGenerator(
rescale=1./255,
#featurewise_std_normalization=True,
#samplewise_std_normalization=False,
featurewise_center=True,
samplewise_center=True,
validation_split=0.30)
train_generator = train_datagen.flow_from_dataframe(
dataframe=trainLabels,
directory='resized_train_cropped/resized_train_cropped/',
x_col="image",
y_col="level",
target_size=(224, 224),
batch_size=10,
class_mode='categorical',
color_mode='rgb', #quitar o no quitar
subset='training')
validation_generator = train_datagen.flow_from_dataframe(
dataframe=trainLabels,
directory='resized_train_cropped/resized_train_cropped/',
x_col="image",
y_col="level",
target_size=(224, 224),
batch_size=10,
class_mode='categorical',
subset='validation')
model=Sequential()
model.add(vgg16.VGG16(include_top=False, weights='imagenet', input_tensor=None, input_shape=(224,224,3), pooling=None, classes=5))
model.add(Flatten())
model.add(Dense(4096, activation='relu', name='fc1'))
model.add(Dropout(0.5))
model.add(Dense(4096, activation='relu', name='fc2'))
model.add(Dropout(0.5))
model.add(Dense(5, activation='softmax', name='predictions'))
model.compile(loss='categorical_crossentropy',
optimizer='adam',
metrics=['acc', 'mse'])
log_dir="logs\\fit\\" +'Prueba'+ datetime.datetime.now().strftime("%Y%m%d-%H%M%S")
tensorboard_callback = TensorBoard(log_dir=log_dir, histogram_freq=1)
parada=callbacks.callbacks.EarlyStopping(monitor='val_loss',mode='min',verbose=1,restore_best_weights=True)
learningRate=callbacks.callbacks.ReduceLROnPlateau(monitor='val_loss', factor=0.1, verbose=1, mode='min', min_delta=0.0001, cooldown=0, min_lr=0)
model.fit_generator(
train_generator,
steps_per_epoch=500,
epochs=10,
validation_data=validation_generator,
validation_steps=100,
validation_freq=1,
callbacks=[tensorboard_callback,parada,learningRate])
Here I leave the code with what I have so far. One of my main questions is how to use the featurewise_std_normalization, samplewise_std_normalization, featurewise_center and samplewise_center attributes. Which give me a warning that I must do a "fit" first to the images, but I don't know how to do it. I think this can be one of the keys to improve.
If anyone can give me some advice I would be very grateful.