syft.workers.websocket_client

Module Contents

syft.workers.websocket_client.logger
syft.workers.websocket_client.TIMEOUT_INTERVAL = 999999
class syft.workers.websocket_client.WebsocketClientWorker(hook, host: str, port: int, secure: bool = False, id: Union[int, str] = 0, is_client_worker: bool = False, log_msgs: bool = False, verbose: bool = False, data: List[Union[torch.Tensor, AbstractTensor]] = None)

Bases: syft.workers.base.BaseWorker

property url(self)
connect(self)
close(self)
search(self, query)
_send_msg(self, message: bin, location=None)
_forward_to_websocket_server_worker(self, message: bin)
_recv_msg(self, message: bin)

Forwards a message to the WebsocketServerWorker

_send_msg_and_deserialize(self, command_name: str, *args, **kwargs)
list_objects_remote(self)
objects_count_remote(self)
clear_objects_remote(self)
async async_fit(self, dataset_key: str, return_ids: List[int] = None)

Asynchronous call to fit function on the remote location.

Parameters
  • dataset_key – Identifier of the dataset which shall be used for the training.

  • return_ids – List of return ids.

Returns

See return value of the FederatedClient.fit() method.

fit(self, dataset_key: str, **kwargs)

Call the fit() method on the remote worker (WebsocketServerWorker instance).

Note: The argument return_ids is provided as kwargs as otherwise there is a miss-match with the signature in VirtualWorker.fit() method. This is important to be able to switch between virtual and websocket workers.

Parameters
  • dataset_key – Identifier of the dataset which shall be used for the training.

  • **kwargs – return_ids: List[str]

evaluate(self, dataset_key: str, return_histograms: bool = False, nr_bins: int = -1, return_loss=True, return_raw_accuracy: bool = True)

Call the evaluate() method on the remote worker (WebsocketServerWorker instance).

Parameters
  • dataset_key – Identifier of the local dataset that shall be used for training.

  • return_histograms – If True, calculate the histograms of predicted classes.

  • nr_bins – Used together with calculate_histograms. Provide the number of classes/bins.

  • return_loss – If True, loss is calculated additionally.

  • return_raw_accuracy – If True, return nr_correct_predictions and nr_predictions

Returns

  • loss: avg loss on data set, None if not calculated.

  • nr_correct_predictions: number of correct predictions.

  • nr_predictions: total number of predictions.

  • histogram_predictions: histogram of predictions.

  • histogram_target: histogram of target values in the dataset.

Return type

Dictionary containing depending on the provided flags

__str__(self)

Returns the string representation of a Websocket worker.

A to-string method for websocket workers that includes information from the websocket server

Returns

The Type and ID of the worker