fed_learn package

class Message(topic: str, body)

Bases: object

get_header(key, default=None)
get_ref_id(default=None)
set_header(key, value)
set_headers(headers: dict)
set_ref_id(msg_id)
class MsgHeader

Bases: object

REF_MSG_ID = '_refMsgId'
RETURN_CODE = '_rtnCode'
class ReturnCode

Bases: object

ERROR = '_error'
OK = '_ok'
error_reply(err: str) → fed_learn.admin_defs.Message
ok_reply(data=None) → fed_learn.admin_defs.Message

Utilities for federated learning

class EventType

Bases: object

Defines FL workflow events.

BEFORE_AGGREGATION = '_beforeAggregation'
CLIENT_QUIT = '_clientQuit'
CLIENT_REGISTER = '_clientRegister'
END_AGGREGATION = '_endAggregation'
END_ROUND = '_endRound'
GET_MODEL = '_getModel'
RECEIVE_CONTRIBUTION = '_receiveContribution'
RECEIVE_MODEL = '_receiveModel'
RECEIVE_VALIDATION_MODEL = '_receiveValidationModel'
RECEIVE_VALIDATION_RESULTS = '_receiveValidationResults'
SEND_BEST_MODEL = '_sendBestModel'
SEND_MODEL = '_sendModel'
SEND_VALIDATION_RESULTS = '_sendValidationResults'
START_ROUND = '_startRound'
SUBMIT_LOCAL_BEST_MODEL = '_submitLocalBestModel'
exception FLAdminException(message)

Bases: Exception

FL Admin exceptions

exception FLCommunicationException(exception)

Bases: Exception

Base class for fed_learn communication exceptions

class MessageCompressor

Bases: object

compress(model)
decompress(model)
class ModelEncryptor

Bases: fed_learn.model_transformer.ModelTransformer

decode(model)
encode(model)
class ApplicationContext

Bases: dict

class FLContext

Bases: dict

add_metadata(field: str, value)

add a metadata into the FLContext.

Parameters
  • field – metadata field name

  • value – medadata field value

clone()
get_all_metadata()
get_metadata(field)
get_model()
get_prop(key, default=None)
set_metadata(metadata: dict)
set_model(model: fed_learn.protos.federated_pb2.ModelData)
set_prop(key, value)
set_props(props: dict)
class ModelTransformer

Bases: abc.ABC

abstract decode(model)
abstract encode(model)

NumPy ndarray to protobuf serialization and deserialization

ndarray_to_proto(nda: numpy.ndarray) → fed_learn.protos.federated_pb2.NDArray

Serializes a numpy array into an NDArray protobuf message. :param nda: numpy array to serialize. :type nda: np.ndarray

Returns

Returns an NDArray protobuf message.

proto_to_ndarray(nda_proto: fed_learn.protos.federated_pb2.NDArray) → numpy.ndarray

Deserializes an NDArray protobuf message into a numpy array. :param nda_proto: NDArray protobuf message to deserialize. :type nda_proto: NDArray

Returns

Returns a numpy.ndarray.

© Copyright 2020, NVIDIA. Last updated on Feb 2, 2023.