net_lib

Module Contents

load_data(trainset, testset)

flush_memory()

train_model(net, trainloader, epochs, device)

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

train_scaffold(net, server_c, client_c, trainloader, ...)

Trains a given neural network using the Scaffold algorithm.

train_fedavg(net, trainloader, epochs, device)

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

train_fedprox(net, trainloader, epochs, device, mu)

Trains a given neural network using the Federated Proximal (Fedprox) algorithm.

test_model(net, testloader, device)

fedadam(initial_state_dict, trained_state_dict)

train_feddyn(net, trainloader, epochs, device, prev_grads)

Trains a given neural network using the FedDyn algorithm.

load_data(trainset, testset)
flush_memory()
train_model(net, trainloader, epochs, device)

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_scaffold(net, server_c, client_c, trainloader, epochs, device)

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

train_fedavg(net, trainloader, epochs, device)

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_fedprox(net, trainloader, epochs, device, mu)

Trains a given neural network using the Federated Proximal (Fedprox) 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)
fedadam(initial_state_dict, trained_state_dict)
train_feddyn(net, trainloader, epochs, device, prev_grads)

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