MATLAB Answers

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

33 views (last 30 days)
Parsia Basimfar
Parsia Basimfar on 24 Oct 2019
Answered: Ba Mo on 30 Oct 2019
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.

  0 Comments

Sign in to comment.

Answers (2)

Ajay Pattassery
Ajay Pattassery on 29 Oct 2019
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

  0 Comments

Sign in to comment.


Ba Mo
Ba Mo on 30 Oct 2019
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.

  0 Comments

Sign in to comment.