Failed test cases for graded functions

I submitted the code to the grader and I received weird failed test cases, for which I don’t have any idea why it is happening:

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
.

All tests passed for train_val_generators!

Details of failed tests for create_model

Failed test case: There was an error grading this function. Details shown in ‘got’ value below:.
Expected:
no exceptions,
but got:
[Errno 2] No such file or directory: ‘./data/images/’.

Can anyone point out the reason why it is happening and what to look out for in the code?

If you aren’t doing the following:

  1. Hardcoding paths instead of using paths in function parameters (especially when creating generators)
  2. Deleting a directory accidentally.

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

Please don’t use os.chdir in the program without changing it back to the previous location. The effect of changing directory is permanent and not local to the function. If you look at your code, there’s no need for it the call to change the directory as you are creating the full path to the source file.

There’s one more bug in your implementation of split_data. Read the instructions again to fix it.

Please don’t iterate over a list and remove from it within the same iteration.
Here’s an example where things go wrong:

>>> items = ["one", "two", "three", "four"]
>>> for item in items:
...     if len(item) == 3:
...             items.remove(item)
... 
>>> items
['two', 'three', 'four']

Using a collection to track of things to remove is a better approach:

>>> items = ["one", "two", "three", "four"]
>>> to_remove = set()
>>> for item in items:
...     if len(item) == 3:
...             to_remove.add(item)
... 
>>> items = [item for item in items if item not in to_remove]
>>> items
['three', 'four']

you sure the start code here and end code here exists?

Hi Yash.
Here’s an example snippet where the markers exist in the starter code:

def split_data(SOURCE_DIR, TRAINING_DIR, VALIDATION_DIR, SPLIT_SIZE):
  """
  Splits the data into train and test sets
  
  Args:
    SOURCE_DIR (string): directory path containing the images
    TRAINING_DIR (string): directory path to be used for training
    VALIDATION_DIR (string): directory path to be used for validation
    SPLIT_SIZE (float): proportion of the dataset to be used for training
    
  Returns:
    None
  """

  ### START CODE HERE
  pass

  ### END CODE HERE