Train and validator generator. Always needed?

In the first course, last week, there is no validation data?

Example:

  train_generator = train_datagen.flow_from_directory(directory="./data_lets_say",
                                                        target_size=(50, 50),
                                                        batch_size=128,
                                                        class_mode="binary")

now we have (second course, first lab):

# --------------------
# Flow training images in batches of 20 using train_datagen generator
# --------------------
train_generator = train_datagen.flow_from_directory(train_dir,
                                                    batch_size=20,
                                                    class_mode='binary',
                                                    target_size=(150, 150))     
# --------------------
# Flow validation images in batches of 20 using test_datagen generator
# --------------------
validation_generator =  test_datagen.flow_from_directory(validation_dir,
                                                         batch_size=20,
                                                         class_mode  = 'binary',
                                                         target_size = (150, 150))

how is possible that the first case (no validation_generator) worked at all? I must be missing something. What? Thanks.

Training without a validation set is perfectly acceptable but you will lose information such as if your model is overfitting or not.

1 Like

I fully agree with @a-zarta .

Btw, there are some Coursera materials that you can use to get into this topic deeply.

Try to grab a couple of :coffee: or :tea: and watch those, then you must upgrade yourself smoothly.

Hopefully, it helps :smiling_face: