size of output of fully connected layer and size of input in matlab

In MATLAB, the size of the output of a fully connected layer can be calculated using the following formula:

main.m
outputSize = inputSize * numNeurons
36 chars
2 lines

Where inputSize is the size of the input to the layer and numNeurons is the number of neurons in the layer.

For example, if the input to the layer has a size of 10 and the layer has 5 neurons, then the output size will be:

main.m
outputSize = 10 * 5
outputSize = 50
36 chars
3 lines

To get the size of the input to the fully connected layer, you can use the size function in MATLAB. For example, if your input data is stored in a matrix X, then the size of the input will be:

main.m
inputSize = size(X, 2)
23 chars
2 lines

This will return the number of columns in the matrix X, which corresponds to the size of the input to the fully connected layer.

gistlibby LogSnag