Question: def softmax(x): 1| II II Compute softmax function for a batch of input values. The first dimension of the input corresponds to the batch size.

def softmax(x): 1| II II Compute softmax function for a batch of input values. The first dimension of the input corresponds to the batch size. The second dimension corresponds to every class in the output. When implementing softmax, you should be careful to only sum over the second dimension. Important Note: You must be careful to avoid overflow for this function. Functions like softmax have a tendency to overflow when very large numbers like eA10000 are computed. You will know that your function is overflow resistent when it can handle input like: np.array([[i0000, 10010, 10]]) without issues. Args: x: A 2d numpy float array of shape batch_size x number_of_classes Returns: A 2d numpy float array containing the softmax results of shape batch_size x number_of_classes 1| II II # *** START CODE HERE *** # *** END CODE HERE ***
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
