ENH/CLN: replace sub-classing Engine/Model methods with callbacks / classes
we want to avoid subclassing for code sharing
WRT this, engine.Model should still be used for training / predicting / etc., but
- the pseudo-private
_train,_predictetc should be removed from the class- original design was that a user would sub-class Model and override these methods if necessary
- instead these should be functions defined external to the class as
default_train_func,default_predict_func, etc. - each method should now accept an argument
something_func, a callback that defaults to the corresponding default for that method. E.g.Model.predict(predict_func=default_predict_func) - alternatively go for full-on classes and allow each method to accept a
Trainer,Predictor, etc., argument with a defined interface but no other constraints on what's passed in? Again with a default
I think we should just rename Engine and pass in torch.Module models. This feels like the most explicit API that best provides composability: there's an engine, it takes in models and functions and uses the function to do things with the models
Closing because after switching to lightning as a backend in #597 this is no longer needed; one can write custom train_step, predict_step, etc., for models, achieving the same thing, and the core lightning.Trainer similarly has many hooks and allows for callbacks during training