0
$\begingroup$

I have read few articles some say there is no need to have no. of units in output layer = no. of classes why some say they both should be equal.

My questions are

  1. If no. of neurons = no. of classes. How are the classes mapped to each neuron/unit in the output layer. To elaborate how does Neural Network decide which neuron/unit deals with which class.

  2. After training a neural network using tensorflow on a multiclass classification problem using softmax in out put layer and no. of units in output layer = no. of classes. When I use this trained network on test sample, the output is a numpy array of probabilities of each class. How do I whther the first element of that array represents which class.

  3. If no. of units is not equal to no. of classes can some one share a link of such an example for multiclass problems.

$\endgroup$
  • $\begingroup$ can you provide a link to article where they mention that no. of output units is not equal to number of classes? $\endgroup$ – Ruchit Vithani Jul 19 at 7:26
  • $\begingroup$ @RuchitVithani This is the stack over flow answer I found as such it does make sense but I dont know will it work? stackoverflow.com/questions/21773913/… $\endgroup$ – Hitesh Somani Jul 19 at 8:14
1
$\begingroup$

In multiclass classification problems, the number of output units (i.e. neurons) is equal to the number of classes. Only in binary classification, you have 2 classes but just 1 output unit.

  1. The mapping between output units and classes is decided by you. You assign each class an index from $0$ to $N-1$, where $N$ is the number of classes. This values (or one-hot versions of them) are what you supply as expected output to the loss function. Output units form a vector of size $N$, with each unit being at a specific position in that vector. The unit at position $i$ represents the class with index $i$.

  2. The output of the softmax is also a vector of $N$ probability values. The probability at position $i$ represents the probability of the input data belonging to the class with index $i$.

| improve this answer | |
$\endgroup$
  • $\begingroup$ I use to follow the same. Basically encode classes to numbers using label encoding and then output unit 1 represent class 1 and likewise and in prediction the first element of the vector is the out put of the first unit and like wise. But can you provide me with and research paper or article/blog or video tutorial proving this. I am quiet interested to see the while training how does only first neuron produce higher number/probability for class 1, and second neuron produces largest number for class 2. $\endgroup$ – Hitesh Somani Jul 19 at 8:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.