XENO
XENO

Reputation: 1

Could not understand the output of this neural network

I have given an input array(3000,1) and the output i expect is a multi - probability of 0,1,2. i have scaled my inputs between 0 and 1 then why is my output coming over 1 and what are those hyphenated numbers along with it .

enter code here

training_input, training_label = shuffle(training_input, training_label)

# training_input range from 1-100 so we scale it down to between 0-1
scaler = MinMaxScaler(feature_range=(0, 1))
scaled_training_input = scaler.fit_transform(training_input.reshape(-1, 1))

model = tf.keras.models.Sequential()

model.add(tf.keras.layers.Dense(16, input_shape=(1,), activation='relu'))
model.add(tf.keras.layers.Dense(32, activation='relu'))
model.add(tf.keras.layers.Dense(3, activation='softmax'))
[enter image description here][1]


  [1]: https://i.sstatic.net/OXEmG.png

Upvotes: 0

Views: 66

Answers (2)

Pircaptain
Pircaptain

Reputation: 3

The activation function softmax is in exponential form. So your output will exceed 1.

Upvotes: 0

Saim Bonda
Saim Bonda

Reputation: 91

The elements of output array are the probabilities of the instance to belong to class 0, 1 and 2 respectively.

To make the prediction you will have to go with the class with highest probability.

The hyphens represent negative powers, i.e. 9.99e-01 is 0.999
Therefore all the numbers are less than one and their sum is one.

To round:

import numpy as np
pred = (np.random.rand(27) ** 5).reshape(-1,3) #sample output
np.round(pred, 2) #rounds to show only a few decimals

enter image description here

enter image description here

Upvotes: 1

Related Questions