fl_server_core.models ¶
Modules:
| Name | Description |
|---|---|
metric | |
model | |
training | |
user | |
Classes:
| Name | Description |
|---|---|
GlobalModel | Model class for global models. |
LocalModel | Model class for local models. |
MeanModel | Model class for mean models. |
Metric | Metric model class. |
Model | Base model class for all types of model models. |
SWAGModel | Model class for SWAG models. |
Training | Training model class. |
User | User class. |
Attributes¶
__all__ module-attribute ¶
__all__ = ['GlobalModel', 'LocalModel', 'Metric', 'MeanModel', 'Model', 'SWAGModel', 'Training', 'User']
Classes¶
GlobalModel ¶
Bases: Model
flowchart TD
fl_server_core.models.GlobalModel[GlobalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.Model --> fl_server_core.models.GlobalModel
click fl_server_core.models.GlobalModel href "" "fl_server_core.models.GlobalModel"
click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
Model class for global models.
- API Reference
fl_server_coretests
- API Reference
fl_server_coremodels
- API Reference
-
fl_server_core -
fl_server_apiserializersmodel AttributesGlobalModelSerializer
-
Methods:
| Name | Description |
|---|---|
get_preprocessing_torch_model | Converts the preprocessing to a PyTorch model. |
set_preprocessing_torch_model | Sets the preprocessing from a PyTorch model. |
Attributes:
| Name | Type | Description |
|---|---|---|
description | TextField | Description of the model. |
input_shape | ArrayField | Input shape of the model. |
name | CharField | Name of the model. |
preprocessing | BinaryField | Preprocessing of the model. |
Source code in fl_server_core/models/model.py
Attributes¶
description class-attribute instance-attribute ¶
Description of the model.
input_shape class-attribute instance-attribute ¶
Input shape of the model.
name class-attribute instance-attribute ¶
Name of the model.
preprocessing class-attribute instance-attribute ¶
Preprocessing of the model.
Functions¶
get_preprocessing_torch_model ¶
Converts the preprocessing to a PyTorch model.
Returns:
| Type | Description |
|---|---|
Module | torch.nn.Module: The PyTorch model. |
LocalModel ¶
Bases: Model
flowchart TD
fl_server_core.models.LocalModel[LocalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.Model --> fl_server_core.models.LocalModel
click fl_server_core.models.LocalModel href "" "fl_server_core.models.LocalModel"
click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
Model class for local models.
- API Reference
fl_server_coretests
- API Reference
-
fl_server_apiserializersmodel AttributesLocalModelSerializer -
fl_server_coreadmin Classes
-
Methods:
| Name | Description |
|---|---|
get_training | Gets the training associated with the base model. |
Attributes:
| Name | Type | Description |
|---|---|---|
base_model | ForeignKey | Base model of the local model. |
sample_size | IntegerField | Sample size of the local model. |
Source code in fl_server_core/models/model.py
Attributes¶
base_model class-attribute instance-attribute ¶
base_model: ForeignKey = ForeignKey(GlobalModel, on_delete=CASCADE)
Base model of the local model.
sample_size class-attribute instance-attribute ¶
Sample size of the local model.
Functions¶
MeanModel ¶
Bases: GlobalModel
flowchart TD
fl_server_core.models.MeanModel[MeanModel]
fl_server_core.models.model.GlobalModel[GlobalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.GlobalModel --> fl_server_core.models.MeanModel
fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
click fl_server_core.models.MeanModel href "" "fl_server_core.models.MeanModel"
click fl_server_core.models.model.GlobalModel href "" "fl_server_core.models.model.GlobalModel"
click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
Model class for mean models.
- API Reference
-
fl_server_aiuncertainty -
fl_server_apiserializersmodel AttributesMeanModelSerializer
-
Methods:
| Name | Description |
|---|---|
get_torch_model | Converts the models to a PyTorch model. |
set_torch_model | Sets the models from a PyTorch model. |
Attributes:
| Name | Type | Description |
|---|---|---|
models | ManyToManyField | Models of the mean model. |
Source code in fl_server_core/models/model.py
Attributes¶
models class-attribute instance-attribute ¶
models: ManyToManyField = ManyToManyField(GlobalModel, related_name='mean_models')
Models of the mean model.
Functions¶
get_torch_model ¶
Converts the models to a PyTorch model.
Returns:
| Type | Description |
|---|---|
Module | torch.nn.Module: The PyTorch model. |
Source code in fl_server_core/models/model.py
Metric ¶
Bases: Model
flowchart TD
fl_server_core.models.Metric[Metric]
click fl_server_core.models.Metric href "" "fl_server_core.models.Metric"
Metric model class.
- API Reference
fl_server_apiserializersgeneric AttributesMetricSerializer
Methods:
| Name | Description |
|---|---|
is_binary | Check if the value of the metric is binary. |
is_float | Check if the value of the metric is a float. |
to_torch | Convert the binary value of the metric to a torch module or tensor. |
Attributes:
| Name | Type | Description |
|---|---|---|
identifier | CharField | Identifier of the metric. |
key | CharField | Key of the metric. |
model | ForeignKey | Model associated with the metric. |
reporter | ForeignKey | User who reported the metric. |
step | IntegerField | Step of the metric. |
value | float | bytes | Value of the metric. |
value_binary | BinaryField | Binary value of the metric. |
value_float | FloatField | Float value of the metric. |
Source code in fl_server_core/models/metric.py
Attributes¶
identifier class-attribute instance-attribute ¶
Identifier of the metric.
key class-attribute instance-attribute ¶
Key of the metric.
model class-attribute instance-attribute ¶
model: ForeignKey = ForeignKey(Model, on_delete=CASCADE)
Model associated with the metric.
reporter class-attribute instance-attribute ¶
reporter: ForeignKey = ForeignKey(User, null=True, blank=True, on_delete=CASCADE)
User who reported the metric.
step class-attribute instance-attribute ¶
Step of the metric.
value deletable property writable ¶
value_binary class-attribute instance-attribute ¶
Binary value of the metric.
value_float class-attribute instance-attribute ¶
Float value of the metric.
Functions¶
is_binary ¶
is_binary() -> bool
Check if the value of the metric is binary.
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool |
|
is_float ¶
is_float() -> bool
Check if the value of the metric is a float.
Returns:
| Name | Type | Description |
|---|---|---|
bool | bool |
|
to_torch ¶
Convert the binary value of the metric to a torch module or tensor.
Returns:
| Type | Description |
|---|---|
Module | Tensor | Module | Tensor: The converted torch module or tensor. |
Source code in fl_server_core/models/metric.py
Model ¶
Bases: PolymorphicModel
flowchart TD
fl_server_core.models.Model[Model]
click fl_server_core.models.Model href "" "fl_server_core.models.Model"
Base model class for all types of model models.
- API Reference
-
fl_server_apiserializersmodel Functions -
fl_server_coremodelsmodel Functionsclone_model
-
- API Reference
fl_server_coremodels
- API Reference
-
fl_server_ai -
fl_server_core -
fl_server_apiserializersmodel
-
Methods:
| Name | Description |
|---|---|
get_torch_model | Converts the model weights to a PyTorch model. |
get_training | Gets the training associated with the model. |
is_global_model | Checks if the model is a global model. |
is_local_model | Checks if the model is a local model. |
set_torch_model | Sets the model weights from a PyTorch model. |
Attributes:
| Name | Type | Description |
|---|---|---|
id | UUIDField | Unique identifier for the model. |
owner | ForeignKey | User who owns the model. |
round | IntegerField | Round number of the model. |
weights | BinaryField | Weights of the model. |
Source code in fl_server_core/models/model.py
Attributes¶
id class-attribute instance-attribute ¶
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
Unique identifier for the model.
owner class-attribute instance-attribute ¶
owner: ForeignKey = ForeignKey(User, on_delete=CASCADE)
User who owns the model.
round class-attribute instance-attribute ¶
Round number of the model.
weights class-attribute instance-attribute ¶
Weights of the model.
Functions¶
get_torch_model ¶
Converts the model weights to a PyTorch model.
Returns:
| Type | Description |
|---|---|
Module | torch.nn.Module: The PyTorch model. |
get_training ¶
get_training() -> Training | None
Gets the training associated with the model.
Returns:
| Type | Description |
|---|---|
Training | None | models.Training: The training associated with the model. |
Source code in fl_server_core/models/model.py
is_global_model ¶
Checks if the model is a global model.
Returns:
| Name | Type | Description |
|---|---|---|
bool | True if the model is a global model, False otherwise. |
is_local_model ¶
Checks if the model is a local model.
Returns:
| Name | Type | Description |
|---|---|---|
bool | True if the model is a local model, False otherwise. |
SWAGModel ¶
Bases: GlobalModel
flowchart TD
fl_server_core.models.SWAGModel[SWAGModel]
fl_server_core.models.model.GlobalModel[GlobalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.GlobalModel --> fl_server_core.models.SWAGModel
fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
click fl_server_core.models.SWAGModel href "" "fl_server_core.models.SWAGModel"
click fl_server_core.models.model.GlobalModel href "" "fl_server_core.models.model.GlobalModel"
click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
Model class for SWAG models.
- API Reference
-
fl_server_aiuncertainty -
fl_server_apiserializersmodel AttributesSWAGModelSerializer
-
Attributes:
| Name | Type | Description |
|---|---|---|
first_moment | Tensor | Gets the first moment of the SWAG model. |
second_moment | Tensor | Gets the second moment of the SWAG model. |
swag_first_moment | BinaryField | First moment of the SWAG model. |
swag_second_moment | BinaryField | Second moment of the SWAG model. |
Source code in fl_server_core/models/model.py
Attributes¶
first_moment property writable ¶
Gets the first moment of the SWAG model.
Returns:
| Name | Type | Description |
|---|---|---|
Tensor | Tensor | The first moment of the SWAG model. |
second_moment property writable ¶
Gets the second moment of the SWAG model.
Returns:
| Name | Type | Description |
|---|---|---|
Tensor | Tensor | The second moment of the SWAG model. |
swag_first_moment class-attribute instance-attribute ¶
First moment of the SWAG model.
swag_second_moment class-attribute instance-attribute ¶
Second moment of the SWAG model.
Training ¶
Bases: Model
flowchart TD
fl_server_core.models.Training[Training]
click fl_server_core.models.Training href "" "fl_server_core.models.Training"
Training model class.
- API Reference
fl_server_coremodels
- API Reference
-
fl_server_ai-
trainer -
uncertainty -
notification -
aggregation
-
-
fl_server_apiserializersgeneric -
fl_server_coremodelstraining Functionspost_save_training
-
Attributes:
| Name | Type | Description |
|---|---|---|
actor | ForeignKey | User who is the actor of the training. |
aggregation_method | CharField | Aggregation method used in the training. |
id | UUIDField | Unique identifier for the training. |
last_update | Time of the last update. | |
locked | BooleanField | Flag indicating whether the training is locked. |
model | OneToOneField | Model used in the training. |
options | JSONField | Options for the training. |
participants | ManyToManyField | Users who are the participants of the training. |
state | CharField | State of the training. |
target_num_updates | IntegerField | Target number of updates for the training. |
uncertainty_method | CharField | Uncertainty method used in the training. |
Source code in fl_server_core/models/training.py
Attributes¶
actor class-attribute instance-attribute ¶
actor: ForeignKey = ForeignKey(User, on_delete=CASCADE, related_name='actors')
User who is the actor of the training.
aggregation_method class-attribute instance-attribute ¶
aggregation_method: CharField = CharField(max_length=32, choices=choices, default=FED_AVG)
Aggregation method used in the training.
id class-attribute instance-attribute ¶
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
Unique identifier for the training.
last_update class-attribute instance-attribute ¶
Time of the last update.
locked class-attribute instance-attribute ¶
Flag indicating whether the training is locked.
model class-attribute instance-attribute ¶
model: OneToOneField = OneToOneField(Model, on_delete=CASCADE)
Model used in the training.
options class-attribute instance-attribute ¶
options: JSONField = JSONField(default=dict, encoder=DjangoJSONEncoder)
Options for the training.
participants class-attribute instance-attribute ¶
participants: ManyToManyField = ManyToManyField(User)
Users who are the participants of the training.
state class-attribute instance-attribute ¶
State of the training.
target_num_updates class-attribute instance-attribute ¶
Target number of updates for the training.
User ¶
Bases: AbstractUser, NotificationReceiver
flowchart TD
fl_server_core.models.User[User]
fl_server_core.models.user.NotificationReceiver[NotificationReceiver]
fl_server_core.models.user.NotificationReceiver --> fl_server_core.models.User
click fl_server_core.models.User href "" "fl_server_core.models.User"
click fl_server_core.models.user.NotificationReceiver href "" "fl_server_core.models.user.NotificationReceiver"
User class.
Inherits from Django's AbstractUser and NotificationReceiver.
- API Reference
-
fl_server_api-
teststest_user ClassesUserTests FunctionsassertUserEqual -
serializersuser ClassesUserSerializer Functions
-
-
fl_server_coremodels
-
Attributes:
| Name | Type | Description |
|---|---|---|
actor | BooleanField | Flag indicating whether the user is an actor. |
client | BooleanField | Flag indicating whether the user is a client. |
id | UUIDField | Unique identifier for the user. |
message_endpoint | URLField | Endpoint to send the message to. |
Source code in fl_server_core/models/user.py
Attributes¶
actor class-attribute instance-attribute ¶
Flag indicating whether the user is an actor.
client class-attribute instance-attribute ¶
Flag indicating whether the user is a client.
id class-attribute instance-attribute ¶
id: UUIDField = UUIDField(primary_key=True, editable=False, default=uuid4)
Unique identifier for the user.
message_endpoint class-attribute instance-attribute ¶
Endpoint to send the message to.