Not defining backward loss leads to an 'Abstract classes cannot be instantiated' error. Why is that?

14 次查看(过去 30 天)
Using the examples given in a Mathworks document I implemented my own neural network layer without defining the backward loss, which results in the following error message:
"Abstract classes cannot be instantiated. Class 'weightAdditionLayer' inherits abstract methods or properties but does not implement them. See the list of methods and properties that 'weightAdditionLayer' must implement if you do not intend the class to be abstract."
The meaning of the error message is clear to me. What is unclear is the fact that the mathworks implementation does not define the backward loss function and explicitly says that this is optional, as the class is able to find the derivative itself. Although I haven't tested the Mathworks code I assume it works. I want to know why I am getting this error message after all despite that I am following mathworks' example.

回答(2 个)

Ajay Pattassery
Ajay Pattassery 2019-10-29
I think your MATLAB version is R2019a or earlier and you are referring to the documentation of R2019b.
In MATLAB R2019a and earlier versions, while creating the custom neural network layer, we need to create a backward function. It is not optional. Refer the same document in R2019a
If you want to refer to the documentation of previous releases, you could refer

Ba Mo
Ba Mo 2019-10-30
Same problem occurs with the deep learning toolbox
Abstract classes cannot be instantiated. Class 'maeRegressionLayer' inherits ...
abstract methods or properties but does not implement them. Use ...
meta.abstractDetails to see the list of methods and properties that ...
'maeRegressionLayer' must implement if you do not intend the class to be ...
abstract.
Abstract classes cannot be instantiated. Class 'preluLayer' inherits ...
abstract methods or properties but does not implement them. Use ...
meta.abstractDetails to see the list of methods and properties that ...
'preluLayer' must implement if you do not intend the class to be ...
abstract.

类别

Help CenterFile Exchange 中查找有关 Parallel and Cloud 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by