Train Network
- class train.MainModule[source]
Bases:
objectClass that defines the main module that will be used to train, test and predict with different medical models.
- predict(args, log_dir, device, root_dir='.')[source]
Function to predict with the model. Call the specific dataset and model, and predict with the model.
- Parameters:
args (argparse.Namespace) – Arguments from the command line.
log_dir (str) – Log directory
device (torch.device) – Device to be used
root_dir (str, optional) – Root path dir. Defaults to “.”.
- test(args, log_dir, device, root_dir='.')[source]
Function to test the model. Call the specific dataset and model, and test the model.
- Parameters:
args (argparse.Namespace) – Arguments from the command line.
log_dir (str) – Log directory
device (torch.device) – Device to be used
root_dir (str, optional) – Root path dir. Defaults to “.”.
- class train.Net(args)[source]
Bases:
LightningModuleClass that defines the Lightning Module that will be used for training, validation and testing.
- configure_optimizers()[source]
Function that configures the optimizer to be used during training.
- Returns:
Optimizer to be used during training
- Return type:
torch.optim.adamw.AdamW
- forward(x)[source]
Function that performs a forward pass on the network.
- Parameters:
x (torch.Tensor | monai.data.meta_tensor.MetaTensor) – Input data to the network
- Returns:
Output data from the network
- Return type:
(torch.Tensor | monai.data.meta_tensor.MetaTensor)
- on_test_epoch_end()[source]
Function that performs an action at the end of the test epoch.
- Returns:
Dictionary containing the tensorboard logs
- Return type:
dict
- on_validation_epoch_end()[source]
Function that performs an action at the end of the validation epoch.
- Returns:
Dictionary containing the tensorboard logs
- Return type:
dict
- test_step(batch, batch_idx)[source]
Function that performs the test step on the network.
- Parameters:
batch (dict) – The batch of data to be used for training
batch_idx (int) – The index of the batch
- Returns:
Dictionary containing the loss and the tensorboard logs
- Return type:
dict