NeVerTools / pyNeVer

A Python library for learning and verification of neural networks and other machine learning models
Other
9 stars 3 forks source link

Refactor nodes.py #24

Closed sdemarch closed 2 months ago

sdemarch commented 5 months ago

Restructure the module nodes.py to represent single- and multi-input/output layers

darioguidotti commented 5 months ago

We need to keep in mind that if we use the classes of networks.py also as containers of nodes defined in abstraction.py we need to do one of two things:

  1. We need to keep a common ancestor between the concrete and abstract layer nodes (which must have only identifier as attribute).
  2. We need to change the current implementation of the abstract layer nodes (#25) so that it make sense to inherit from something defining the attributes in_dims, out_dims. Maybe by inheriting from the corresponding concrete node instead of keeping it as an attribute? Keeping it as an attribute is kind of useful because it keep separate the info regarding the original concrete node from the info needed for the abstract transformer forward.

P.s. the overlapping of the nomenclature between abstract interpretation and abstraction in programming is agony.

sdemarch commented 5 months ago

I think the best solution is to do the same thing as for the AbsNeuralNetwork classes as you say in pt. 2. We make the base class AbsLayerNode acting as an interface and then all "concrete abstract" layers inheriting from both the interface and their respective concrete reference node.

EDIT: this cannot work since LayerNodes constructors would affect the building of AbsLayerNodes

I also think that it can be safe and self-healing to refer to wholly abstract classes as Interfaces

sdemarch commented 5 months ago

Cfr. #25

Also, we implement a getter for in_dim in single-input layers and out_dim for completeness. It performs nothing, but is the right way to structure the interface of the classes