Hydra pipelines#
Pipelines and utils#
Pipeline for running SGMCMC algorithms. |
|
Function that performs the a basic training loop for estimating the maximum likelihood (MLE) or maximum a posteriori (MAP). |
|
Function that sweeps through a test dataset and outputs the model predictions. |
- batorch.utils.pipelines.train_loop(num_epoch, model, train_loader, val_loader, optimizer, scheduler, loglike, writer, device, fold=1)[source]#
Function that performs the a basic training loop for estimating the maximum likelihood (MLE) or maximum a posteriori (MAP).
- Parameters
num_epoch – Number of sweeps through the dataset.
model – Neural network.
train_loader – Dataloader that sweeps through the training dataset.
val_loader – Dataloader that sweeps through the validation dataset.
optimizer – Optimizer.
scheduler – Step size scheduler
loglike – Negative log likelihood function
writer – Tensorboard summary writer
device – Device to be used (cpu or cuda)
fold – The fold number, defaults to 1
- Returns
Dictionnary with losses
- batorch.utils.pipelines.test_loop(model, test_loader, loglike, writer, device, fold=1, enable_dropout=False)[source]#
Function that sweeps through a test dataset and outputs the model predictions.
- Parameters
model – Neural network
test_loader – Dataloader that sweeps through a test dataset
loglike – Negative log likelihood function
writer – Tensorboard SummaryWriter
device – Device to be used (cpu or cuda)
- Returns
Dictionnary with losses and predictions
- batorch.utils.pipelines.mcmc(sampler: Sampler, datamodule: DataModule, max_burnin_iterations: int, max_sampling_iterations: int, device: torch.device, quantization=None)[source]#
Pipeline for running SGMCMC algorithms.
- Parameters
sampler – SGMCMC sampler.
datamodule – DataModule holding at least a training dataset and a test dataset.
max_burnin_iterations – Number of burnin iterations.
max_sampling_iterations – Number of iterations after burnin.
device – Device (cuda or cpu).
quantization – Quantization object, default is None.
Entry points#
- hydra_entries.mcmc_pipeline(config: omegaconf.DictConfig)#
Pipeline for Bayesian regression with SGMCMC methods.
The input configuration file is parsed by hydra and passed to
mcmc().- Parameters
config – Configuration given by a
omegaconf.DictConfig.
- hydra_entries.map_pipeline(config: omegaconf.DictConfig)#
Pipeline for maximum a posteriori or maximum likelihood estimation.
The input configuration file is parsed by hydra. The functions
train_loop()andbatorch.utils.pipelines.test_loop()are used to train the model.- Parameters
config – Configuration given by a
omegaconf.DictConfig.
- hydra_entries.ensemble_pipeline(config: omegaconf.DictConfig)#
Pipeline for Bayesian regression with ensembles.
The input configuration file is parsed by hydra. The functions
train_loop()andbatorch.utils.pipelines.test_loop()are used to train an ensemble of models.- Parameters
config – Configuration given by a
omegaconf.DictConfig.
- hydra_entries.mcdropout_pipeline(config: omegaconf.DictConfig)#
Pipeline for Bayesian regression Monte Carlo dropout.
The input configuration file is parsed by hydra. The input configuration file is parsed by hydra. The functions
train_loop()andbatorch.utils.pipelines.test_loop()are used to perform Monte Carlo dropout.- Parameters
config – Configuration given by a
omegaconf.DictConfig.