strategy_client
StrategyClient()
¶
Bases: ABC
Implement the strategy of client.
Attributes:
Name | Type | Description |
---|---|---|
_custom_handlers |
Dict[str, Any]
|
custom handlers |
_trainer_config |
Dict[str, Any]
|
the trainer config of client |
_current_stage |
Stage
|
current stage of client |
_aggregate_result |
aggregate model parameters result with grpc format |
|
_aggregate_result_np |
aggregate model parameters result with numpy format |
|
_aggregate_c |
None |
|
_smpc |
bool
|
use smpc to start federated learning if _smpc is True |
_sum_random_value |
random value using in smpc |
Source code in iflearner/business/homo/strategy/strategy_client.py
Stage
¶
Bases: IntEnum
Enum the stage of client.
aggregate_result()
¶
get the aggregated model parameters.
Returns:
Type | Description |
---|---|
homo_pb2.AggregateResult
|
homo_pb2.AggregateResult: the aggregated model parameters of grpc format |
Source code in iflearner/business/homo/strategy/strategy_client.py
current_stage()
¶
the current stage, which is in Waiting, Trainning or Settinh stage.
Returns:
Name | Type | Description |
---|---|---|
Stage |
Stage
|
the current stage |
generate_registration_info()
¶
generate_upload_param(epoch, data, metrics=None)
¶
Generate the message of MSG_UPLOAD_PARAM.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
epoch |
int
|
Current epoch of number of client training. |
required |
data |
Dict[Any, Any]
|
The data that will be uploaded to server. |
required |
metrics |
Dict[str, Any]
|
The client metrics. |
None
|
Returns:
Name | Type | Description |
---|---|---|
Any |
Any
|
The grpc format data that can be send to server |
Source code in iflearner/business/homo/strategy/strategy_client.py
handler_aggregate_result(data)
¶
Handle the message of MSG_AGGREGATE_RESULT from the server.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
homo_pb2.AggregateResult
|
the aggregated result from server |
required |
Source code in iflearner/business/homo/strategy/strategy_client.py
handler_notify_training()
¶
set_current_stage(stage)
¶
set_global_param(param)
¶
set global parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param |
Dict[str, Any]
|
parameters |
required |
set_trainer_config(config)
¶
set trainer config.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
config |
Dict[str, Any]
|
the config of client Trainer |
required |
update_param(data)
¶
Update the parameter during training.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data |
homo_pb2.AggregateResult
|
the aggregated result from server |
required |
Returns:
Type | Description |
---|---|
homo_pb2.AggregateResult
|
homo_pb2.AggregateResult: the updated result |