ehrapy.ml.Trainer#
- class ehrapy.ml.Trainer(*, max_epochs=100, batch_size=128, learning_rate=0.001, weight_decay=0.0001, patience=10, class_weight=None, device='auto')[source]#
How deep learning models are trained.
Training stops once the loss on the tuning set has not improved for patience epochs, and the parameters of the epoch with the lowest loss are kept.
Examples
>>> import ehrapy as ep >>> model = ep.ml.GRU(trainer=ep.ml.Trainer(max_epochs=20, device="cpu"))
Attributes table#
Number of observations per gradient step. |
|
"balanced" to weigh classes and labels inversely to their frequency in the training set. |
|
Device to train and predict on, such as "cpu" or "cuda", or "auto" for a GPU if one is available. |
|
Learning rate of the AdamW optimizer. |
|
Maximum number of passes over the training set. |
|
Number of epochs without improvement on the tuning set after which training stops. |
|
Weight decay of the AdamW optimizer. |
Methods table#
Attributes#
- Trainer.class_weight: Literal['balanced'] | None = None#
“balanced” to weigh classes and labels inversely to their frequency in the training set.
- Trainer.device: str = 'auto'#
Device to train and predict on, such as “cpu” or “cuda”, or “auto” for a GPU if one is available.