WK4 Lab 2: model.fit and accuracy during training

Hi there,

I have a couple of questions related to the exercises in Lab2 in week 4:

  1. In the lectures you say that if we are loading the training set using ImageDataGenerator, we should use model.fit_generator (and not model.fit) when training the CNN. Yet, in Lab 2 you use model.fit even though the ImageDataGenerator is used to load training data. Could you please clarify why model.fit is used here, or is this version-specific?

  2. The accuracy during training at each epoch jumps up and down substantially, reaching high 90s and then dropping as low as 70s, and going back up and down again. In the lectures you mention that this can be a result of overfitting (if I remember correctly). In a real world application, in contrast to a learning exercise, would this magnitude of changes be of concern? In other words, should we be implementing some practices to avoid/fix this issue?

Hi @Kasia_Kenitz,

About your first question, let’s see what are differences between both approaches.

  • fit method loads data in memory, what can be a bit optimistic when dealing with real problems. No data augmentation is used.

  • As the name suggests, the fit_generator function assumes there is an underlying function that is generating the data for it. Data is not loaded into memory, so it works quite well for real world problems.

Now, with current TF versions, this discussion is pointless as fit_generator is going to be decommissioned in a near future. :slight_smile:

About your second topic, yes accuracy jumping is not a good signal. During next lessons, you will find ways to optimice this behaviour for real world applications.

Hope it helps,