I’m trying to implement a multiclass logistic regression classifier that distinguishes between k different classes. This is my code. I can verify that cost and gradient are returning values that are in the right dimension (cost returns a scalar, and gradient returns a 1 by n row vector), but i get the error why is this happening and how can
Tag: divide-by-zero
How to return 0 with divide by zero
I’m trying to perform an element wise divide in python, but if a zero is encountered, I need the quotient to just be zero. For example: I could always just use a for-loop through my data, but to really utilize numpy’s optimizations, I need the divide function to return 0 upon divide by zero errors instead of ignoring the error.