pytorch_trainer
PyTorchTrainer(model)
¶
Bases: Trainer
implement the 'get' and 'set' function for the usual pytorch trainer.
Source code in iflearner/business/homo/pytorch_trainer.py
get(param_type=Trainer.ParameterType.ParameterModel)
¶
get parameters form the client, maybe the model parameter or gradient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
param_type |
Trainer.ParameterType
|
Param_type is ParameterModel or ParameterGradient, default is ParameterModel. |
Trainer.ParameterType.ParameterModel
|
Returns:
Type | Description |
---|---|
Dict[str, npt.NDArray[np.float32]]
|
dict, k: str (the parameter name), v: np.ndarray (the parameter value) |
Source code in iflearner/business/homo/pytorch_trainer.py
set(parameters, param_type=Trainer.ParameterType.ParameterModel)
¶
set parameters to the client, maybe the model parameter or gradient.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
parameters |
Dict[str, npt.NDArray[np.float32]]
|
Parameters is the same as the return of 'get' function. |
required |
param_type |
Trainer.ParameterType
|
Param_type is ParameterModel or ParameterGradient, default is ParameterModel. |
Trainer.ParameterType.ParameterModel
|