Week 2 assignment 2, detect 3 classes instead of 2

Hi,

I am facing a problem when running image_dataset_from_directory function. I know there are only two classes in data folder (alpaca, not alpaca) but when I tested using train_dataset.class_names, it shows [’.ipynb_checkpoints’, ‘alpaca’, ‘not alpaca’]. I think just because of this, my submission got an error (Cell #19. Can’t compile the student’s code. Error: AssertionError(‘Error in test’))

can you please give me any directions to solve the problem, specifically how to remove .ipynb_checkpoints file?

Very interesting! I have seen those .ipynb_checkpoints directories before, but have never seen them cause a problem. They are created when you click “File → Save and Checkpoint”. But the ones I have seen only get created at the top level of the workspace directory hierarchy. What you have is the case that the checkpoints directory is created in the datasets subdirectory. I’m not sure how that could happen, but it’s relatively easy to remove that subdirectory. Click “File → Open”. From that window, click “New → Terminal”. Now you have a linux shell. I hope you are at least a little bit familiar with how that works. Try a few commands like “pwd” and “ls” to get a sense of where you are in the file system tree. Then do:

cd W2A2/datasets

to get to the datasets directory. Now do this command:

rm -rf .ipynb_checkpoints

That should do it, assuming the command does not throw an error. To get back to your running notebook, you can click “Work in Browser” again. There’s a way to do it directly from the terminal screen, but it’s a bit more complicated. See if you can click around and figure it out.

That’s the good news. Now for the bad news: I created that situation in my notebook and I see the three class names instead of 2, but the grader still accepts my code with no problem.

So the bad news is that there is also some other problem in your notebook in addition to this strange directory.

Thanks Paul! I’ll try it out.

Hopefully it will through the grader. Definitely will check if there’re some other problems blocking this.

Hi Paul,

just an update on the problem. Using the method you provided, I was able to remove the .ipynb_checkpoints and there are only two classes in the directory now. I was able to successfully run the code (previously, the training result was weird and the accuracy value stopped at one point every epoch, I think ‘the third’ class might confuse the optimizer). But anyway, I can run the model smoothly and get a great result. The most important thing is that by doing this, my submission passed the grader.

Hi, Jack.

It is great that you got your notebook to pass the grader! I still think there must have been something else you changed in the process, because I added that extra directory, saw the 3 classes, but the grader still liked my code. The same as you describe, I did see some weird effects during the training with the 3 classes and the accuracy was really bad.

Oh, well, if you got it to work, let’s be happy with that and move on! :nerd_face:

Cheers,
Paul