During exercise 7 (softmax) of week 2 programming assignment I define a variable as the “exp” variable, a sum variable, and a normalized variable of the exp divided by the sum. This all went fine. However the notebook then says to print out the shapes to see how they are different sizes and the program still runs due to broadcasting. My only question is that when I print the shapes of the three variables, I get the correct sizes for each of the 3… but it prints the 3 shapes of the matrices, it prints the softmax output, then it prints the shapes again of the 3 matrices 3 additional times. I’m not sure why its printing these shapes a total of 4 times? I’m not sure how posting code on here works with the honor code so please let me know if I need to clarify what I’m referring to here.
TLDR; print out shapes of different matrices with the softmax exercise and it prints out the shapes a total of 4 times.
Thanks
There are other test cases besides the one you can see in the notebook. What does the function softmax_test
do? If you want to find out, click “File → Open” and then open the file public_tests.py
and have a look at the contents of that file. Note that there is a general topic about this on the DLS FAQ Thread.
1 Like
Hello,
Thank you for your response.
the program softmax test performs 3 operations and returns an array ‘s’. It appears when I open up the public tests that there are 3 test cases. So it is running through the program 3 different times? Would this explain why its printing out my shapes 3 additional times?
shape size a
shape size b
shape size c
softmax array:
shape size a
shape size b
shape size c
shape size a
shape size b
shape size c
shape size a
shape size b
shape size c
Yes, the softmax
function gets invoked a total of 4 times:
Once directly in the test cell and 3 times by the softmax_test
function.
1 Like