stefanradev93 / BayesFlow

A Python library for amortized Bayesian workflows using generative neural networks.
https://bayesflow.org/
MIT License
297 stars 45 forks source link

Use Training Strategy Pattern in Trainer #125

Closed LarsKue closed 2 months ago

LarsKue commented 6 months ago

The current implementation of bayesflow.trainers.Trainer implements several training strategies in one large class. This can be problematic for both maintainers and users, since

  1. Implementing a new strategy from outside bayesflow requires inheriting from the Trainer class
  2. Modifying small parts of a strategy outside of its input parameters can be difficult or impossible
  3. Maintaining a mental overview over the Trainer functionality is impeded.

We can remedy these issues by implementing the trainer strategies explicitly as their own concept, and following composition over inheritance in the Trainer class.

stefanradev93 commented 6 months ago

That's a very important one! Especially since we want to add some new strategies in the process.

LarsKue commented 2 months ago

Superceded by the removal of the trainer object