fed_learn package

Subpackages

Submodules

fed_learn.admin_defs module

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

fed_learn.fed_utils module

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'

fed_learn.fl_exception module

exception FLAdminException(message)

Bases: Exception

FL Admin exceptions

exception FLCommunicationException(exception)

Bases: Exception

Base class for fed_learn communication exceptions

fed_learn.message_compressor module

class MessageCompressor

Bases: object

compress(model)
decompress(model)

fed_learn.messageproto module

message_to_proto(message: fed_learn.admin_defs.Message)fed_learn.protos.admin_pb2.Message
proto_to_message(proto: fed_learn.protos.admin_pb2.Message)fed_learn.admin_defs.Message

fed_learn.model_encryptor module

class ModelEncryptor

Bases: fed_learn.model_transformer.ModelTransformer

decode(model)
encode(model)

fed_learn.model_meta module

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)

fed_learn.model_transformer module

class ModelTransformer

Bases: abc.ABC

abstract decode(model)
abstract encode(model)

fed_learn.numproto module

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.

Module contents