nlgm.train
Module#
- nlgm.train.train_and_evaluate(model, train_loader, test_loader, epochs=10, device=device(type='cpu'), progress_bar=True)[source]#
Trains and evaluates a model using the given train and test data loaders.
- Args:
model (nn.Module): The model to train and evaluate. train_loader (torch.utils.data.DataLoader): The data loader for training data. test_loader (torch.utils.data.DataLoader): The data loader for test data. epochs (int, optional): The number of epochs to train the model. Defaults to 10. device (torch.device, optional): The device to use for training. Defaults to torch.device(“cpu”). progress_bar (bool, optional): Whether to display a progress bar during training. Defaults to True.
- Returns:
tuple: A tuple containing the list of train losses and the test loss.