openfl.plugins.frameworks_adapters.keras_adapter.FrameworkAdapterPlugin#
- class openfl.plugins.frameworks_adapters.keras_adapter.FrameworkAdapterPlugin[source]#
Bases:
FrameworkAdapterPluginInterfaceFramework adapter plugin class.
Methods
__init__()Initialize framework adapter.
get_tensor_dict(model[, optimizer, suffix])Extract tensor dict from a model and an optimizer.
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 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