To compute the forward pass of a fully connected layer in MATLAB, you can use the fullyConnectedLayer function from the Deep Learning Toolbox. Here's an example of how to do it with a weight matrix of shape 25x25, a bias vector of shape 1x25, an input of shape 25x1, and a batch size of 2:
main.m379 chars19 lines
The repmat function is used to create a batch of inputs by repeating the same input batchSize times along the third dimension. The predict function is used to compute the forward pass of the layer for the batch of inputs. The resulting output is of shape 25x1x2, where the third dimension corresponds to the batch size.
gistlibby LogSnag