Skip to content

Base Trainer

BaseBayesTrainer

Bases: Generic[ModelT], ABC

Abstcract trainer class that is used to provide simple interface to train bayesian modules. Could be used to create your trainers.

Source code in src/methods/bayes/base/trainer.py
class BaseBayesTrainer(Generic[ModelT], ABC):
    """Abstcract trainer class that is used to provide simple interface to train 
    bayesian modules. Could be used to create your trainers."""
    def __init__(
        self,
        params: TrainerParams,
        report_chain: Optional[ReportChain],
        train_dataset: Iterable,
        eval_dataset: Iterable,
    ):
        """_summary_

        Args:
            params (TrainerParams): trianing params that is used to fine-tune training
            report_chain (Optional[ReportChain]): All callback that should be return by each epoch
            train_dataset (Iterable): Dataset on which model should be trained
            eval_dataset (Iterable): Dataset on which epoch of training model should be evaluated
        """
        self.params = params
        """Storing any trianing params that is used to fine-tune training"""
        self.report_chain = report_chain
        """All callback that should be return by each epoch"""
        self.train_dataset = train_dataset
        """Dataset on which model should be trained"""
        self.eval_dataset = eval_dataset
        """Dataset on which epoch of training model should be evaluated"""

    @abstractmethod
    def train(self, *args, **kwargs) -> BaseNetDistribution:
        """It simply train provided model with tarin parameters that is stores in params

        Returns:
            BaseNetDistribution: Distribution of nets that could be used
            to sample models or getting map estimation (the most probable) by result of train.
        """
        ...

eval_dataset = eval_dataset instance-attribute

Dataset on which epoch of training model should be evaluated

params = params instance-attribute

Storing any trianing params that is used to fine-tune training

report_chain = report_chain instance-attribute

All callback that should be return by each epoch

train_dataset = train_dataset instance-attribute

Dataset on which model should be trained

__init__(params, report_chain, train_dataset, eval_dataset)

summary

Parameters:

Name Type Description Default
params TrainerParams

trianing params that is used to fine-tune training

required
report_chain Optional[ReportChain]

All callback that should be return by each epoch

required
train_dataset Iterable

Dataset on which model should be trained

required
eval_dataset Iterable

Dataset on which epoch of training model should be evaluated

required
Source code in src/methods/bayes/base/trainer.py
def __init__(
    self,
    params: TrainerParams,
    report_chain: Optional[ReportChain],
    train_dataset: Iterable,
    eval_dataset: Iterable,
):
    """_summary_

    Args:
        params (TrainerParams): trianing params that is used to fine-tune training
        report_chain (Optional[ReportChain]): All callback that should be return by each epoch
        train_dataset (Iterable): Dataset on which model should be trained
        eval_dataset (Iterable): Dataset on which epoch of training model should be evaluated
    """
    self.params = params
    """Storing any trianing params that is used to fine-tune training"""
    self.report_chain = report_chain
    """All callback that should be return by each epoch"""
    self.train_dataset = train_dataset
    """Dataset on which model should be trained"""
    self.eval_dataset = eval_dataset
    """Dataset on which epoch of training model should be evaluated"""

train(*args, **kwargs) abstractmethod

It simply train provided model with tarin parameters that is stores in params

Returns:

Name Type Description
BaseNetDistribution BaseNetDistribution

Distribution of nets that could be used

BaseNetDistribution

to sample models or getting map estimation (the most probable) by result of train.

Source code in src/methods/bayes/base/trainer.py
@abstractmethod
def train(self, *args, **kwargs) -> BaseNetDistribution:
    """It simply train provided model with tarin parameters that is stores in params

    Returns:
        BaseNetDistribution: Distribution of nets that could be used
        to sample models or getting map estimation (the most probable) by result of train.
    """
    ...