Mentor help needed

When I did the assignment (Python basics with numpy), I passed all tests except one, but i believe my code is right.
Because I can not disclose my codes, I need a mentor help to discuss this private.
Thank for your help in advance

Please post a screen capture image that shows any error messages or asserts.
That’s often sufficient for a mentor to diagnose the issue.

Thank you Tom for replying,

Attached, my lab file in pdf see pages 18-19 two tests passed but one failed, the image is a replication on my own jupyter notebook.

Please help

Franklin Viloria

{moderator edit: notebook code removed}

By the notebook comments, it looks like the softmax() function is supposed to work on the rows, but yours is working on the columns.

Please don’t share your code on the forum, I have deleted your PDF file since it contains your code for the entire notebook.

1 Like

Thank you Tom, you are right,

I finally get it working correctly, but I have to use two for/range loops.

How could I avoid this two for loops and take advantage of vectorization?

Let me learn the tricks of numpy

Franklin viloria

{moderator edit: code removed}


Don’t worry I found the solution doing internet search, thank you anyway

Franklin Viloria

{moderator edit: code removed}

I imagine you can use an “axis = …” parameter, rather than a transposition.

Okay, without transpose

{moderator edit: code removed}

Perhaps axis=1 isn’t the best choice. Have you tried others?
Also you might explore the keepdims parameter.

The notebook file I’m looking at mentions that in the comments for the softmax() function.

I’m rather curious why your softmax() function doesn’t include the doctext that is shown in the notebook:


Because I am not using the lab environment, I am not using the doctest provided

OK. You’re rather on your own then.

1 Like

Sorry I could not figure out how to get rid of the for/range loops, I submitted the attached softmax solution and all test were passed

{moderator edit: code removed}

Are you doing a Course assignment or just practicing in your local environment?