Custom layer/reshape fully connected layer
14 views (last 30 days)
Rahmawati Rahmawati on 28 Apr 2021
I am currently working in encoder decoder architecture but I have to use fully connected layer. Turns out it gains an error because the vector size is becoming 1D after fully connected layer. Before entering into decoder part I need to reorganize into original matrix for example 100x100x3. Is there any hints how to handle this issue?
Divya Gaddipati on 10 May 2021
While there is no built-in 'Reshape' layer to convert the output from the fully connected layer, you can define a custom layer that can act as a reshaping layer after the fully connected layer. For more information on creating custom layers (refer to the 'Intermediate Layer Template' in the 'Layer Templates' section), refer to the following documentation link:
You can set up the layer to reshape the output from the fully connected layer to a 2D matrix in the 'predict' method and vice versa in the 'backward' method. The other methods are optional and you can leverage them based on your use case. MATLAB provide a 'reshape' function that you could use to perform these operations: