I was working on a project and I had this question in mind out of curiosity. It’d be great if some light could be shed on this.
So, I was thinking of creating an abstract base class for defining networks using PyTorch for use in a specific system. So, users could sub-class this base class and define their models.
I was interested in calculating the names of each layer and their number of trainable parameters for each model.
Obviously, I could put in an abstractmethod so that each user could have a flexibility in defining their networks and they could have the responsibility to calculate the number of parameters and names of each layers in their networks.
However, is there a design pattern or approach I could follow to make sure that instead of putting that burden on the user to calculate these things, they only share the responsibility to define the network structure ? And I could write a general function which they could call directly in order to find out the names of each layer and number of parameters ?
For example, Inception and Alexnet are defined in very different ways due to obvious reasons. So, while for a Sequential model, I could write up a function, but then it would not directly work for Inception. Would it ?
Is there any correct approach ?