"Example: Define Custom Deep Learning Layer with Learnable Parameters" doesn't work
11 views (last 30 days)
Show older comments
Hellow, I wrote this question due to getting error for abstract method inheritance.
The example is here: https://kr.mathworks.com/help/deeplearning/ug/define-custom-deep-learning-layer.html
In this example, The written class file in the part named 'Completed Layer' is just used to test for the below 'check validity of Layer Using checkLayer' part:
layer = preluLayer(20,'prelu');
validInputSize = [24 24 20];
checkLayer(layer,validInputSize,'ObservationDimension',4)
But, in 'layer = preluLayer(20, 'prelu'); part, the error message was created: "Creating an instance of the Abstract class is not allowd"
Actually, I know the nnet.layer.Layer object has 2 abstract method named as 'predict' and 'backward', and this example just define 'predict' so the error will be from undefining 'backward'. Even though, I just had followed the example but I got error.
Could you please some tips to resolve this problem?
0 Comments
Accepted Answer
Asvin Kumar
on 23 Dec 2019
Thanks for pointing this out. Check out the complete file by running the following command:
edit(fullfile(matlabroot,'examples','nnet','main','preluLayer.m'))
This file contains the implementation for the backward function too.
As mentioned in the example, it is not required to implement a backward function for layers whose predict/forward functions use only dlarray supported functions. In this example, the predict uses layer.Alpha which is created using randn. The randn function has a limitation for dlarray support. It works when used along with the ‘like’ argument.
1 Comment
More Answers (0)
See Also
Categories
Find more on Deep Learning Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!