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