Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

The output of a softmax isn't supposed to have zeros, right?

I am working on a net in tensorflow which produces a vector which is then passed through a softmax which is my output.

Now I have been testing this and weirdly enough the vector (the one that passed through softmax) has zeros in all coordinate but one.

Based on the softmax's definition with the exponential, I assumed that this wasn't supposed to happen. Is this an error?

EDIT: My vector is 120x160 =192000. All values are float32

like image 366
Alperen AYDIN Avatar asked Aug 23 '16 19:08

Alperen AYDIN


People also ask

What is the output of a softmax function?

Softmax is an activation function that scales numbers/logits into probabilities. The output of a Softmax is a vector (say v ) with probabilities of each possible outcome. The probabilities in vector v sums to one for all possible outcomes or classes.

Which of the following statements are correct about the softmax function?

Softmax is a function that finds the probabilities of all the classes such that they sum to 1. Why S2 is correct ? If we are using a softmax, in order for the probability of one class to increase, the probabilities of at least one of the other classes has to decrease by an equivalent amount.

What is the sum of all the outputs from the softmax function?

It ensures that all the output values of the function will sum to 1 and each be in the range (0, 1), thus constituting a valid probability distribution. The number of classes in the multi-class classifier.


1 Answers

It may not be an error. You need to look at the input to the softmax as well. It is quite possible this vector has very negative values and a single very positive value. This would result in a softmax output vector containing all zeros and a single one value.

You correctly pointed out that the softmax numerator should never have zero-values due to the exponential. However, due to floating point precision, the numerator could be a very small value, say, exp(-50000), which essentially evaluates to zero.

like image 88
ahaque Avatar answered Sep 29 '22 06:09

ahaque