fl_server_core.models.model ¶
Classes:
| Name | Description |
|---|---|
GlobalModel | Model class for global models. |
LocalModel | Model class for local models. |
MeanModel | Model class for mean models. |
MeanModule | PyTorch module for mean models. |
Model | Base model class for all types of model models. |
SWAGModel | Model class for SWAG models. |
Functions:
| Name | Description |
|---|---|
clone_model | Copies a model instance in the database |
Attributes:
| Name | Type | Description |
|---|---|---|
TModel | |
Attributes¶
Classes¶
GlobalModel ¶
Bases: Model
flowchart TD
fl_server_core.models.model.GlobalModel[GlobalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
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 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.model.LocalModel[LocalModel]
fl_server_core.models.model.Model[Model]
fl_server_core.models.model.Model --> fl_server_core.models.model.LocalModel
click fl_server_core.models.model.LocalModel href "" "fl_server_core.models.model.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.model.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.model.MeanModel
fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
click fl_server_core.models.model.MeanModel href "" "fl_server_core.models.model.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
MeanModule ¶
Bases: Module
flowchart TD
fl_server_core.models.model.MeanModule[MeanModule]
click fl_server_core.models.model.MeanModule href "" "fl_server_core.models.model.MeanModule"
PyTorch module for mean models.
Methods:
| Name | Description |
|---|---|
__init__ | Initializes the mean models. |
forward | Forward pass of the mean models. |
Attributes:
| Name | Type | Description |
|---|---|---|
models | Models of the mean model. |
Source code in fl_server_core/models/model.py
Attributes¶
Functions¶
__init__ ¶
Model ¶
Bases: PolymorphicModel
flowchart TD
fl_server_core.models.model.Model[Model]
click fl_server_core.models.model.Model href "" "fl_server_core.models.model.Model"
Base model class for all types of model models.
- API Reference
-
fl_server_coremodelsmodel Functionsclone_model -
fl_server_apiserializersmodel Functions
-
- API Reference
fl_server_coremodels
- API Reference
-
fl_server_core -
fl_server_ai -
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.model.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.model.SWAGModel
fl_server_core.models.model.Model --> fl_server_core.models.model.GlobalModel
click fl_server_core.models.model.SWAGModel href "" "fl_server_core.models.model.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.
Functions¶
clone_model ¶
Copies a model instance in the database See https://docs.djangoproject.com/en/5.0/topics/db/queries/#copying-model-instances and stackoverflow.com/questions/4733609/how-do-i-clone-a-django-model-instance-object-and-save-it-to-the-database
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
| Model | the model to be copied | required |
Returns:
| Name | Type | Description |
|---|---|---|
Model | Model | New Model instance that is a copy of the old one |