deephealthproject / eddl

European Distributed Deep Learning (EDDL) library. A general-purpose library initially developed to cover deep learning needs in healthcare use cases within the DeepHealth project.
https://deephealthproject.github.io/eddl/
MIT License
34 stars 10 forks source link

Add the name_id of each layer #318

Open salvacarrion opened 2 years ago

salvacarrion commented 2 years ago

The Layer class has a private attribute name_id that is initialized in the constructor. This attribute is used to identify the layer type as the current solution for instance checking (NewType* v = dynamic_cast<NewType*>(old)) requires your compiler to use Run-time type information.

The fix is really simple but has to be applied to each layer. Simply add the "identification name" (common to all instances) to each layer (child classes).

For instance, replace:

LBatchNorm::LBatchNorm(Layer *parent, float momentum, float epsilon, bool affine, string name, int dev, int mem) : LinLayer(name, dev, mem)

with:

LBatchNorm::LBatchNorm(Layer *parent, float momentum, float epsilon, bool affine, string name, int dev, int mem) : LinLayer(name, dev, mem, "batchnorm")