To compute the output of a fully connected layer in a neural network with batch size 2, weight shape of 25x25, bias shape of 1x25, and input shape of 25x2 in matlab
, we can use matrix multiplication.
main.m393 chars13 lines
Here, we first define the inputs with shape 25x2x2, representing the 2 input examples in the batch. We also define the weights with shape 25x25 and the bias with shape 1x25.
To compute the output, we first reshape the inputs to have dimensions (25x2) and perform matrix multiplication with the weights (resulting in a (25x2) matrix). We then reshape this result to have dimensions (1x1x25x2), representing the 2 output examples in the batch. Finally, we add the bias to each output example.
The resulting output should have shape 1x1x25x2, representing the 2 examples in the batch with output dimension of 25.
gistlibby LogSnag