"Example: Define Custom Deep Learning Layer with Learnable Parameters" doesn't work
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
DoGyeom Jeong
el 26 de Nov. de 2019
Comentada: Asvin Kumar
el 9 de En. de 2020
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 comentarios
Respuesta aceptada
Asvin Kumar
el 23 de Dic. de 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 comentario
Más respuestas (0)
Ver también
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!