I have been trying to complete the first exercise of the 1st Programming assignment but not getting any output. The zero_pad function is throwing an Assertion error with the text as : Wrong shape: (10, 9, 9, 8) != (4, 9, 9, 2). I have tried everything but nothing seems to work.
{moderator edit - solution code removed}
A while back I wrote up this little tutorial exercise, maybe it will help…
[I guess the screen capture images embedded in that thread were created on a Japanese language OS, hence the kanji file names showing up in the thumbnail/summary]
1 Like
You should absolutely read the thread that ai_curious has linked above, but I’d say your code looks correct as written. But the code you show would not have produced an output of dimension (10,9,9,8) with that test case. So my theory is that you did not click “Shift-Enter” on the zero_pad function cell since you changed the code. The notebook interface for executable code is definitely not WYSIWYG: if you type new code and then call the function again, it just runs the old code again. You have to actually execute the function cell itself by clicking “Shift-Enter” in order to get the new code to be incorporated into to runtime “JIT” compiled code. The other way to get things to be consistent is “Kernel → Restart and Clear Output” followed by “Cell → Run All”.
You can easily prove to yourself the point I described above by creating a simple experiment. Take a working function and purposely break it, but don’t click “Shift-Enter”. Then click “Shift-Enter” on the test cell that calls the function. It still works, right? Now click “Shift-Enter” on the function cell and then call it again. Booom!
1 Like
Oh, man!! Thanks a lot. This is so embarrassing lol