net_lib

Module Contents

load_data(config)

flush_memory()

train_model(net, trainloader, epochs, device[, deadline])

Trains a neural network model on a given dataset using SGD optimizer with Cross Entropy Loss criterion.

train_fedavg(net, trainloader, epochs, device[, deadline])

Trains a given neural network using the Federated Averaging (FedAvg) algorithm.

train_feddyn(net, trainloader, epochs, device[, deadline])

Trains a given neural network using the FedDyn algorithm.

train_mimelite(net, state, trainloader, epochs, device)

Trains a given neural network using the MimeLite algorithm.

train_mime(net, state, control_variate, trainloader, ...)

Trains a given neural network using the Mime algorithm.

train_scaffold(net, server_c, trainloader, epochs, device)

Trains a given neural network using the Scaffold algorithm.

test_model(net, testloader, device)

Evaluate the performance of a model on a test dataset.

load_data(config)
flush_memory()
train_model(net, trainloader, epochs, device, deadline=None)

Trains a neural network model on a given dataset using SGD optimizer with Cross Entropy Loss criterion. Args:

net: neural network model trainloader: PyTorch DataLoader object for training dataset epochs: number of epochs to train the model deadline: optional deadline time for training

Returns:

trained model with the difference between trained model and the received model

train_fedavg(net, trainloader, epochs, device, deadline=None)

Trains a given neural network using the Federated Averaging (FedAvg) algorithm.

Args: net: A PyTorch neural network model trainloader: A PyTorch DataLoader containing the training dataset epochs: An integer specifying the number of training epochs deadline: An optional deadline (in seconds) for the training process

Returns: A trained PyTorch neural network model

train_feddyn(net, trainloader, epochs, device, deadline=None)

Trains a given neural network using the FedDyn algorithm. Args: net: A PyTorch neural network model trainloader: A PyTorch DataLoader containing the training dataset epochs: An integer specifying the number of training epochs deadline: An optional deadline (in seconds) for the training process

Returns: A trained PyTorch neural network model

train_mimelite(net, state, trainloader, epochs, device, deadline=None)

Trains a given neural network using the MimeLite algorithm.

Args: net: A PyTorch neural network model trainloader: A PyTorch DataLoader containing the training dataset epochs: An integer specifying the number of training epochs deadline: An optional deadline (in seconds) for the training process

Returns: A trained PyTorch neural network model

In the case of MimeLite, control_variate is nothing but a state like in case of momentum method

train_mime(net, state, control_variate, trainloader, epochs, device, deadline=None)

Trains a given neural network using the Mime algorithm.

Args: net: A PyTorch neural network model trainloader: A PyTorch DataLoader containing the training dataset epochs: An integer specifying the number of training epochs deadline: An optional deadline (in seconds) for the training process

Returns: A trained PyTorch neural network model

train_scaffold(net, server_c, trainloader, epochs, device, deadline=None)

Trains a given neural network using the Scaffold algorithm.

Args: net: A PyTorch neural network model trainloader: A PyTorch DataLoader containing the training dataset epochs: An integer specifying the number of training epochs deadline: An optional deadline (in seconds) for the training process

Returns: A trained PyTorch neural network model

test_model(net, testloader, device)

Evaluate the performance of a model on a test dataset.

Args: net (torch.nn.Module): The neural network model to evaluate. testloader (torch.utils.data.DataLoader): The data loader for the test dataset.

Returns: Tuple: The average loss and accuracy of the model on the test dataset.