When you design a neural network, you start with the size of the inputs and you know what kind of answer you want. If you know that the purpose of your neural network is to generate a binary (“yes/no”) answer, then you design the layers in such a way that the output of the last layer is a single value. For every layer of the neural network, you know the size of the input and you get to choose what size of output you want to generate. In other words, you get to choose the number of output neurons from each layer and that becomes the input to the next layer. For the output layer, if you want a “yes/no” answer, then there is only one output neuron from the output layer.
No it was string manipulation between those two Denses.
Of course I know it was matrix algebra. Lol
Now are you able to or can you help us on how it’s done so we the students can understand how a vector of row 3 went from a being a vector to a scaler value for classification?
i think it becomes a scalar only at the final output layer. for example, if we have 4 input features, the first hidden layer has 5 neurons, the second hidden layer has 3 neurons, and the output layer has 1 neuron, the input starts as a vector of 4 values. after the computations in the first hidden layer, each of the 5 neurons outputs one value, so we get a vector of 5 values. the same thing happens in the next hidden layer, giving us a vector of 3 values. finally, since the output layer has only one neuron, it produces a single value that we can compare with a threshold like 0.5 for binary classification.
if the output layer had more than one neuron, then it would depend on the task. for multi-label classification, we can compare each output with a threshold. for multi-class classification, we usually use softmax and choose the output with the highest probability instead.
i hope i understood your question correctly.
To help visualize what @paulinpaloalto mentioned regarding the dimensions:
If the previous layer outputs a 3 × 1 vector 3 features for a single sample, and the current Dense layer has 1 unit, the weight matrix W for this layer will have shape 1 ×3.
\\{Shape of } -W^{[l]} = \\(n^{[l]}, n^{[l-1]}\\)
Where:
n^{[l]} is the number of units in the current layer.
n^{[l-1]} is the number of units in the previous layer