Week 1 PA 2 - Dinosaur island - prob not equal to 1

I am facing an issue in np.random.choice function where the it is throwing an error of probability not equal to 1, i checked the sum manually and it was 0.99…97.

also the shape of my output vector (y) is (27,1) , i have fixed it by dividing all the values with y.sum(), but i am still curious why did it even happened.

please help me out with this.

y is the output of softmax function call. Why divide it by the sum again?

That seems like a doubtful method. Better to fix the issue than throw more code at it.

I think this thread may help you to understand what is the problem.

Hope this helps.