To reshape a fully connected layer in Matlab, you first need to have the Neural Network Toolbox. Within the toolbox, you can use the fullyConnectedLayer
function to create a fully connected layer object.
Once you have a fully connected layer object, you can use the inputSize
method to get the size of the input to the layer. Then, you can use the reshape
function to reshape the weights and biases of the layer to the desired size.
Here's an example:
main.m602 chars16 lines
In this example, fc_layer
is a fully connected layer object with 10 input features and 5 output features. We use the inputSize
method to get the input size of the layer, which is 10. Then, we reshape the weights of the layer from a (10 x 5) matrix to a (10 x 5) matrix using the reshape
function. We also reshape the biases from a (1 x 5) matrix to a (1 x 5) matrix.
Finally, we set the new weights and biases of the layer using the Weights
and Bias
properties of the layer object.
gistlibby LogSnag