Building a Robust Data Pipeline - coding assignment

Regarding the lab- Building a Robust Data Pipeline - coding assignment.

There is a function provided to retrieve the mean and std def get_mean_std(dataset: Dataset): always fails. The data provided for the function is critical to achieve task 2 and subsequent tasks.

Appreciate feedback.

@ymacora

post screenshot of the error you encountered. please make sure when post screenshot, do not include any part of the grade function codes that grades your assignment as it would be considered direct violation of Code of Conduct.

Regards
Dr. Deepti

It sounds like either you didn’t execute the previous cells in the notebook or perhaps you have not completed some required code earlier in the notebook. That error is telling you that the parameter plants_dataset that you passed to get_mean_std has the value None, which means that it was never initialized. So how could that happen?

The first rule of debugging is to extract as much information as you can from the actual error that you are getting. It doesn’t always help, but it’s the first step and in this case it seems to give actionable information. :nerd_face:

@ymacora

First of all please choose right categories when posting a query, your issue is related to course 1 pytorch fundamentals of pytorch for deep learning specialisation but you have posted your query under course 3 of pytorch specialisation.

Now comes to your error, what @paulinpaloalto is mentioning is probably right that you probably missed writing codes for the second half of your first grade function. this could have happened because there two seperate code markers, the first section where you recall from root directory and then at the end for the samples you will find another code marker, you probably missed writing codes there,

remember if the bellow statement :backhand_index_pointing_down: caused confusion


        # Apply the specified transformations to the image, if any
        # The None of the if condition is not part of the exercise, leave it as is
        if self.transform is not None:

Then this None should be left as it is but the subsequent image code need to be recalled with self.transform function for the inage, so plants dataset can get the samples to calculate the mean and standard of dataset samples.

Regards
Dr. Deepti

Hi @ymacora,

Please follow what Paul and Deepti have pointed out.

If the issue remains, feel free to reach out again.

Thanks,
Mubsi

All, Thank you for getting back to me. For clarity all cells had been run. The error occurs in the pipeline, when a normalize dataset is process to get the mean and std. Process 99% (I removed existing error handling). Now I get and out of bounds error. That is clear fix, However this is confusing. When I fix the Out-of-bounds error then the test classes failed.

I just reran the code - started working with no changes. Thank you all for looking into this.

Sorry, but just looking at this from a purely scientific p.o.v. those two statements are contradictory. I can believe that you may have run all the cells at some point in the past, but you have to be very aware of the current state of the notebook. If you manually execute individual cells in the notebook by clicking them in some order, it’s pretty easy to get things into an inconsistent state. Another such example is that if you just type new code into a code cell and then call that function again without actually executing that changed cell, you will be running the old code. You can easily demonstrate this effect to yourself.

It’s always worth trying this sequence to make sure things are consistent and WYSIWYG:

Kernel -> Restart and Clear Output
Cell -> Run All

what is wysiwyg?? @paulinpaloalto

WYSIWYG is “What You See Is What You Get”.

In this case, I “repurposed” the term to mean that the code you are looking at is actually what is being run.

In these notebooks it is very easy to be in the situation where the code that is actually being executed is different than what you are seeing. If you modify a cell, but don’t actually execute that cell and only call the function that it defines, then you end up running an older version of the code.

It’s easy to demonstrate this phenomenon to yourself:

Take a function that you’ve completed and that already passes the unit test case with “All tests passed!”. Now purposely break the function by multiplying the return value by 2:

return 2 * returnValue

Now run the unittest cell for that function again and it still passes! What happened? The problem is just typing code doesn’t actually do anything until you click “Shift-Enter” on the actual changed cell. Now do that: click “Shift-Enter” on the newly broken cell and then run the test again. Kaboom! :weary_cat:

Of course doing “Cell -> Run All” will cause the test to fail as well. The point is that just calling the function does not run the cell again to get the new code incorporated into the runtime kernel image of the notebook.