C2W1 Final Assignment Error in train_val_generators function

Hi, i came across this error in the train_val_generators

Failed test case: There was an error grading this function. Details shown in 'got' value below:.
Expected:
no exceptions,
but got:
must be real number, not NoneType.

this is my code:

# GRADED FUNCTION: train_val_generators
def train_val_generators(TRAINING_DIR, VALIDATION_DIR):
  ### START CODE HERE

  # Instantiate the ImageDataGenerator class (don't forget to set the rescale argument)
  train_datagen = ImageDataGenerator(1./255)

  # Pass in the appropiate arguments to the flow_from_directory method
  train_generator = train_datagen.flow_from_directory(directory=TRAINING_DIR,
                                                      batch_size=100,
                                                      class_mode="binary",
                                                      target_size=(150, 150))

  # Instantiate the ImageDataGenerator class (don't forget to set the rescale argument)
  validation_datagen = ImageDataGenerator(1./255)

  # Pass in the appropiate arguments to the flow_from_directory method
  validation_generator = validation_datagen.flow_from_directory(directory=VALIDATION_DIR,
                                                                batch_size=20,
                                                                class_mode="binary",
                                                                target_size=(150, 150))
  ### END CODE HERE
  return train_generator, validation_generator

i believe this is almost exactly the same with the code from the example earlier in the course. What am i missing?

Please click my name and share your notebook as an attachment.

The problem happens because you’re using list_picture instead of list_picture_2 when you’re sampling for the train / test split.
As a result, you consider files of size 0 and end up with errors.

Fix the lines starting with list_picture_2= random.sample and the next 2 lines of code.

Thanks for the advice. I already change it but the error still the same

Please click my name and share your notebook as an attachment.

Hello,
did you figure the solution out_ I got back the same error.
I checked the function several times, it looks ok to me (it is the same as the last assignment)
Many thanks.

1 Like

I couldn’t figure out what’s wrong yet. Let me know if you manage to find it.

@13218057_Balkan_Khil Please contaact coursera help.

I have the same issue with C2W3 Final Assignment: Transfer Learning - Horses vs Humans.
No way to figure the solution out

@Gloria Please click my name and message your notebook as an attachment.

Hi all! The issue here is with the ImageDataGenerator. Please check the parameter list here. It seems you are trying to set the rescale value but inadvertently used featurewise_center instead. Hope this helps!