Google Colaboratory

[snippet removed by mentor]

I am struggling to catch up with my profound confusion from the beginning of this assignment so I really need help with this and other seemingly incomprehensible error. You will see in line 19 the file designated to create the GLOBAL variable ‘TRAINING_CATS_DIR’ is missing. This sort of funny since the absolute path for the directory used to define the variable ten lines earlier in the code provided by the grader is there.

Plus, in cell #5 where I was called upon to create the working directories, I passed. And you can see the results are in keeping with the directory path in question.

Please help

Doug

I would very much like to work for attaining this certificate. But it is not good for my mental health to attempt to muddle through this mess, especially without assistance. I have had classes with Dr. Ng that were nothing like this one. I can go a long way without support by working through properly documented direction, as all software should be. But in this course there are way too many constant variable with naming schemes that are incomprehensible. I believe my notebook is failing because these variables are defined in the grader code. This seems like bad style. Indeed, PEP 8 recommends that constant notation be used at the module level. Do we really need TRAINING_DIR along with TRAINING_CATS_DIR? This is especially insane when this particular directory is created with os.path.join(TRAINING_DIR, “cats/”). Wouldn’t this more succinctly define this constant to call it TRAINING_DIR_CATS? Furthermore there are several instances of semantic dissonance in the text of the assignment. In the first line we refer to ‘Cats vs Dogs’. Then we go on to download the ‘cats-and-dogs’ data. And finally we fall into the ‘cats-v-dogs’ name. This is inconsistency. I have no idea why the grader objects to my code. Unless it is because the grader uses forward slash notation at the end of a path while the hard-coded instructions in a previous cell did not. This is a customer service issue. I will appreciate some support to reduce the confusion, or I will appreciate a refund of the $50 a month and discontinuance of this billing.

I can’t access your colab notebook since you haven’t set the permission to allow view access via the shared link. Please click my name and message your notebook as an attachment.

TRAINING_CATS_DIR should exist when split_data is tested. /tmp/cats-v-dogs/training/cats should’ve been created in the method create_train_val_dirs.

Please read the markdown instructions carefully and execute cells in the order provided in the notebook.

Right, and it is possible I have identified a flaw in my code for that function, which I will be the first to acknowledge. There is no excuse for lousy style. A primary attribute of the Python language is supposed to be readability. Plus I don’t know about causation, but tf 2.13 has modules that strive to automate machine learning directorie structure. BTW I am in EST.

This method call is supposed to create the directory structure for you.

create_train_val_dirs(root_path=root_dir)

The next code cell which lists the directories should produce the same output as the expected output cell that follows it.

There are 2 problems with your code:

  1. A lambda function is created and doesn’t get invoked. As a result, no directories are made.
  2. The directories you aim to create are incorrect. Have a print statement in the for loop and this’ll be the output:
Creating /tmp/cats-v-dogs/training
Creating /
Creating /
Creating /tmp/cats-v-dogs/validation
Creating /
Creating /
1 Like

Please don’t overthink when you’re on the wrong track. The problem is with your code.
Creating an anonymous function doesn’t run it. You have to explicitly invoke it for the function body to execute.

Here’s an example:

>>> square = lambda number: number ** 2
>>> # invoke the function
>>> square(2)
4

I post replies on the public thread so that other learners who might stumble across the same problem as yours will find the discussion useful.

One suggestion: This is an intermediate level specialization. Consider getting familiar with python on sites like w3schools. Lack of python skills and a ways to think about deep learning problems can stump learners.

If you’re still uncomfortable with this interaction, I’d be happy to get the admins involved to assist you further. Looking forward to hearing from you.

1 Like

() is a good point, Doug. You should also note that none of your lambdas execute.

To show that your lambda function doesn’t get invoked, here’s an example:

>>> root_path='./'
>>> elem='dummy'
>>> lambda elem: (os.mkdirs(os.path.join(root_path, elem)))
<function <lambda> at 0x7f2bdf3f7430>
>>> os.path.exists(os.path.join(root_path, elem))
False

I borrowed this context from the google colab link you shared via this direct message.

Here is a proper invocation of the lambda function (though for this exercise you don’t need a lambda function):

>>> (lambda: os.makedirs(os.path.join(root_path, elem)))()
>>> os.path.exists(os.path.join(root_path, elem))
True

A couple of things for you to learn here:

  1. Invoke a lambda function.
  2. os.mkdirs does’t exist. Use os.makedirs instead. Here’s the stacktace:
1 Like

you win, I am out