Class - FrameworkAdapterPluginInterface#

class openfl.plugins.frameworks_adapters.framework_adapter_interface.FrameworkAdapterPluginInterface[source]#

Bases: object

Framework adapter plugin class.

__init__()[source]#

Initialize framework adapter.

Return type:

None

Methods

__init__()

Initialize framework adapter.

get_tensor_dict(model[, optimizer])

Extract tensor dict from a model and an optimizer.

serialization_setup()

Prepare model for serialization (optional).

set_tensor_dict(model, tensor_dict[, ...])

Set tensor dict from a model and an optimizer.

static get_tensor_dict(model, optimizer=None)[source]#

Extract tensor dict from a model and an optimizer.

Parameters:
  • model (object) – The model object.

  • optimizer (object, optional) – The optimizer object. Defaults to None.

Returns:

A dictionary with weight name as key and numpy ndarray as

value.

Return type:

dict

Raises:

NotImplementedError – This is a placeholder method that needs to be implemented in subclasses.

static serialization_setup()[source]#

Prepare model for serialization (optional).

static set_tensor_dict(model, tensor_dict, optimizer=None, device='cpu')[source]#

Set tensor dict from a model and an optimizer.

Given a dict {weight name: numpy ndarray} sets weights to the model and optimizer objects inplace.

Parameters:
  • model (object) – The model object.

  • tensor_dict (dict) – Dictionary with weight name as key and numpy ndarray as value.

  • optimizer (object, optional) – The optimizer object. Defaults to None.

  • device (str, optional) – The device to be used. Defaults to ‘cpu’.

Returns:

None

Raises:

NotImplementedError – This is a placeholder method that needs to be implemented in subclasses.