server module¶
-
class
server.
Server
(model)[source]¶ Bases:
object
-
get_clients_test_info
(clients=None)[source]¶ Returns the ids, hierarchies and num_test_samples for the given clients.
Returns info about self.selected_clients if clients=None;
Parameters: clients – list of Client objects.
-
select_clients
(possible_clients, num_clients=20)[source]¶ Selects num_clients clients randomly from possible_clients.
- Note that within function, num_clients is set to
- min(num_clients, len(possible_clients)).
Parameters: - possible_clients – Clients from which the server can select.
- num_clients – Number of clients to select; default 20
Returns: list of (num_train_samples, num_test_samples)
-
test_model
(clients_to_test=None)[source]¶ Tests self.model on given clients.
Tests model on self.selected_clients if clients_to_test=None.
Parameters: clients_to_test – list of Client objects.
-
train_model
(num_epochs=1, batch_size=10, minibatch=None, clients=None)[source]¶ Trains self.model on given clients.
Trains model on self.selected_clients if clients=None; each client’s data is trained with the given number of epochs and batches.
Parameters: - clients – list of Client objects.
- num_epochs – Number of epochs to train.
- batch_size – Size of training batches.
- minibatch – fraction of client’s data to apply minibatch sgd, None to use FedAvg
Returns: - number of bytes written by each client to server
dictionary with client ids as keys and integer values.
- client computations: number of FLOPs computed by each client
dictionary with client ids as keys and integer values.
- bytes_read: number of bytes read by each client from server
dictionary with client ids as keys and integer values.
Return type: bytes_written
-