avalanche icon indicating copy to clipboard operation
avalanche copied to clipboard

ADD Meta Learning Template

Open AntonioCarta opened this issue 3 years ago • 2 comments

@HamedHemati

AntonioCarta avatar Jun 29 '22 16:06 AntonioCarta

As discussed in the previous meeting, creating new templates with the current structure will result in lots of code duplicates. For example if we want to have a separate template for meta-learning based strategies we will probably need at least two different templates like MetalearningTemplate and OnlineMetalearningTemplate where most of the code is shared with other SGD-based strategies. To avoid this, as suggested by @AntonioCarta (to use mixin classes in Python), I thought about a different template structure as below. It doesn't necessarily have to be exactly like the one below, but separating the different aspects of a learning strategy can make extensions easier without code duplicates and therefore make it easier to maintain the templates:

To create a new template one can define the template class with the following pattern:

class NAME(problem_type, observation_type, update_type, base_template)

The first three classes are mixin classes, and the last one is the super template class.

Some examples:

class SupervisedTemplate(Supervised, Batch, SGDUpdate, SGDTemplate):
    def __init__(self):
        ...

^ this won't break the existing supervised strategies since all callbacks will remain the same.

class OnlineSupervisedMetaTemplate(Supervised, Online, MetaUpdate, SGDTemplate):
    def __init__(self):
        ...

** This is just an initial idea on how to change the structure, and of course, the split names can be different. @AntonioCarta please let me know your opinion about this type of approach.

HamedHemati avatar Jul 02 '22 20:07 HamedHemati

The splits look ok, we can discuss the details and nomenclature when you have a PR. Remember that multiple inheritance makes things more complex in general:

  • try to avoid it if not really necessary
  • in general, it's best if only one of the parents has internal state, the others should only define methods. For example, problem-type and observation-type shouldn't add new state (but they may define new immutable attributes), while update-type for sure does
  • the end users should not be aware of this internal organization

Try not to make a huge PR. We can do this changes in multiple steps. The main objective here is to add support for meta-learning, not to design some super general framework.

AntonioCarta avatar Jul 04 '22 08:07 AntonioCarta