"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.
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?

採用された回答

Asvin Kumar
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 件)

カテゴリ

Help Center および File ExchangeBuild Deep Neural Networks についてさらに検索

製品


リリース

R2019a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by