C1 W3 perceptron model returns <class 'NoneType'>

I was able to run my code fine in the notebook and pass the tests, but when I submit the assignment for grading I get 0/30 for the forward propogation (and all subsequent functions as a result) and it says

“Failed test case: Object forward_propagation has incorrect type…
Expected:
<class ‘function’>,
but got:
<class ‘NoneType’>.”

I’m not sure what is incorrect when my code is running fine in the virtual notebook. I am new to python, so maybe I’m doing something wrong. Here is my code for the forward propogation function. Does anyone have any insight into why the grader is returning this error?

{moderator edit - solution code removed}

1 Like

Hi @Alex_Fennell
Welcome to the community!
Please make sure from the category of this post, because this post doesn’t belong to Machine learning specialization

Cheers,
Abdelrahman

1 Like

Ah thank you, I have updated it now.

1 Like

I’m pretty sure you’re not supposed to post your code for the graded assignments. Every DLAI course seems to have the same community standards.

1 Like

I’m not an M4ML mentor, but are you sure that you didn’t accidentally change the type of that function cell from “code” to “markdown”? The code you showed looks like a legitimate function, which is why I suggest the theory that the problem is the cell type.

1 Like

That’s a good thought, but I double checked and the block is marked as a code.

1 Like

My apologies I didn’t realize that. I just figured including the code would be the easiest way for someone to verify if my code was doing something funky and not creating a function when it should be.

1 Like

Interesting. I took another look at your code (I reformatted it with the </> tool to make it legible). You can still see it if you click the little pencil icon (at least I can still see it). It does look legitimate and I don’t see any indentation anomalies or the like. The only theory I can come up with is that there is something structural wrong with your notebook or perhaps there are some invisible characters in the first few lines of the cell that are ignored in the Jupyter execution context, but not in the grader context. I’m not an M4ML mentor and don’t have access to the course, so I wouldn’t really be able to do anything if I could get a copy of your notebook. Since none of the M4ML mentors have chimed in, the only thing I can think of to try would be to get a clean copy of the notebook and then very carefully “copy/paste” over just your solution code from the “YOUR CODE HERE” sections and see if that helps.

Here’s a thread that explains how to get a clean copy. It’s from DLS, but the notebook mechanisms are the same in all the courses.

If you go that route, please let us know if that helps or not.

1 Like

What I mean by “structural problems” in your notebook is that the Jupyter notebooks are JSON files and there’s a lot of “metadata” there that you don’t see in the notebook UI, but which is used by the grader. If you touch the notebooks with any tools other than the course website, there is the danger that those tools may alter the metadata in a way that causes problems. One specific example of this that I’ve seen is that someone downloaded an ipynb file, uploaded it and ran it on Google Colab, and then brought that version back to the course website. Chaos ensued. When examining the JSON source, you could see that Colab had territorially marked the notebook with its own style of metadata, which is quite a bit different than the Coursera graders use.

1 Like

Also, be sure you have not renamed the notebook file. The “submit” process always uses the original name of the notebook - not the name of the notebook you have open.

Basically, you can’t submit a re-named notebook for grading.

1 Like

Thank you for the reply. I was able to submit the assignment successfully without that error once I used a clean copy of the notebook! I will be sure to keep that in mind in case this occurs in the future.

2 Likes

That’s great news! Thanks for confirming. You don’t mention anything about using other tools on the notebook, so I guess the cause of whatever the damage or inconsistency was will remain a mystery. But at least we have a remedy if it happens again. Onward! :nerd_face:

1 Like

Yeah I have no idea what caused this issue, because I only used the virtual notebook and edited the code between the designated sections in the assignment. Maybe I clicked something or accidentally did some sort of keyboard shortcut to alter something unknowingly. Regardless I’m glad we got it sorted out.

1 Like