Reputation: 639
The following results are numpy ndarray scores from linear regression[y = Wx + b].
scores = tf.nn.xw_plus_b(self.h_drop, W, b, name='scores')
~ ~ .....
all_scores = np.zeros(shape=(0,len(label_dict)))
~~...
all_scores = np.concatenate((all_scores, batch_scores) , axis=0)
How do I change above numpy ndarray values to ndarray probability values ?
Desired results:
col0 col1 col2 col3 col4 col5
Row1 0.02 | 0.123 | 0.678 | 0.067 | 0.0987 | 0.1089 : Sum(col0~5) = 1
~
Upvotes: 1
Views: 1310
Reputation: 56347
The simplest way is to apply to softmax function:
f(x) = e^x_i / sum_j e^x_j
This will transform values in any range to a vector that sums to one, which can be interpreted as probabilities. A TF function that does this is tf.nn.softmax.
Upvotes: 2