openfl.plugins.frameworks_adapters.keras_adapter.FrameworkAdapterPlugin#

class openfl.plugins.frameworks_adapters.keras_adapter.FrameworkAdapterPlugin[source]#

Bases: FrameworkAdapterPluginInterface

Framework adapter plugin class.

__init__()[source]#

Initialize framework adapter.

Return type:

None

Methods

__init__()

Initialize framework adapter.

get_tensor_dict(model[, optimizer, suffix])

Extract tensor dict from a model and an optimizer.

serialization_setup()

Prepare model for serialization (optional).

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

Set the model weights with a tensor dictionary.

static get_tensor_dict(model, optimizer=None, suffix='')[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.

  • suffix (str, optional) – The suffix for the weight dictionary keys. Defaults to ‘’.

Returns:

A dictionary with weight name as key and

numpy ndarray as value.

Return type:

model_weights (dict)

static serialization_setup()[source]#

Prepare model for serialization (optional).

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

Set the model weights with a tensor dictionary.

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

  • tensor_dict (dict) – The tensor dictionary.

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

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

Returns:

None