airpack_scripts.pytorch.run_training

Module Contents

airpack_scripts.pytorch.run_training.DEVICE
airpack_scripts.pytorch.run_training.train(network, dataloader, optimizer, criterion, scalar)

Train pytorch neural network and return loss and accuracy

Parameters
  • network (torch.nn.Module) – torch model

  • dataloader (torch.utils.data.dataloader) – torch data loader

  • optimizer (torch.optim) – torch optimizer function

  • criterion (torch.nn) – torch loss function

  • scalar (int) – scalar integer to normalize data

Returns

(train_loss, train_acc)

Return type

tuple

airpack_scripts.pytorch.run_training.validate(network, dataloader, criterion, scalar)

Train pytorch neural network and return loss and accuracy

Parameters
  • network (torch.nn.Module) – torch model

  • dataloader (torch.utils.data.dataloader) – torch data loader

  • criterion (torch.nn) – torch loss function

  • scalar (int) –

Param

scalar int to normalize data

Returns

(val_loss, val_acc)

Return type

tuple

airpack_scripts.pytorch.run_training.main(data_folder, n_epoch=10)

Script used to train airpack.pytorch.model.Network.

Note

You may modify the parameters in this script to tune the hyperparameters of the airpack.pytorch.model.Network().

Parameters
  • data_folder (Union[str, os.PathLike]) – Location of training data

  • n_epoch (int) – Number of epochs in training process

Returns

Training accuracy

Return type

float