"Example: Define Custom Deep Learning Layer with Learnable Parameters" doesn't work
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Asvin Kumar
2019-12-23
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.
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!