Skip to main content

Adjustable Components

Forcha Base was projected to be fully adjustable code base that takes off the need to write boilerplate code for Federated Learning. Its components are fully modifiable building blocks that can be adjusted to your needs in a few lines of code. Here, we present a few practical tips that make come in handy when projecting your own simulation.

Writing your own dataset loading method

To change the dataset loading method you should change the Federated Model attach_dataset_id method. This method always allows to assign a particular ID and a dataset to a node, hence it is important to remember, that Forcha Base assigns those two values at one method call (otherwise, you may mistakanely assign a certain dataset to a wrong client, which may influence the simulation's outcome). The baseline attach_dataset_id method is as follows:

    def attach_dataset_id(
        self,
        local_dataset: Any,
        node_name: int | str,
        only_test: bool = False,
        batch_size: int = 32
        ) -> None:

		### Here you should input your code
		self.trainloader = torch.utils.data.DataLoader(
                	your_training_data,
                	batch_size=batch_size,
                	shuffle=True,
                	num_workers=0,
            	)
		self.testloader = torch.utils.data.DataLoader(
                	your_test_data,
                	batch_size=batch_size,
                	shuffle=False,
                	num_workers=0,
            	)

Irrespective of how the data is passed to the method call, it should always be loaded using torch.utils.data.DataLoader. Otherwise, you may need to write a fully custom training loop

Metrics and data structures guidelines

The use of internal data structures should be (if possible) coherent across the whole library. Here we provide a few baseline examples

SimulationInstance.network <- dict[id: FederatedNode]

SimulationInstance.network is a dictionary mapping each node to its respective identificator. It is also a central attribute of the Simulation instance, as it preserves all the nodes participating in the training over the whole instance's lifecycle.

weights <- dict[id: OrderedDict]

Weights (or gradients) of the participant should always be passed in the form of python dictionary, mapping node's ID number to an OrderedDict containing the particular set of weights. This guarantess integrity of all the functions that either accept weights as their argument or return in after processing.

training_results <- [node_id] = 
			{
			"iteration": [int] iteration,
			"node_id": [int] node_id
			"loss": [float] loss_list[-1],  
			"accuracy": [float] accuracy_list[-1],  
			"full_loss": [list] loss_list,  
			"full_accuracy": [list] accuracy_list}

Training results should be preserved in nested dictionary, mapping node_id to the internal dictionary with a following mapping: {str: int, str: int, str: float, str: float, str: list, str: list}. While it is more relax requirement, it may keep the internal structure of the preserved metrix intact.

Metadata

Release files for FedJust 0.1.2.5

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for FedJust 0.1.2.5
File Size Uploaded Provenance
fedjust-0.1.2.5.tar.gz 13.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for FedJust 0.1.2.5
File Interpreter ABI Platform
fedjust-0.1.2.5-py3-none-any.whl Python 3 none any Details

Total release size: 33.2 kB

Release files / fedjust-0.1.2.5.tar.gz

Download URL fedjust-0.1.2.5.tar.gz
Size 13.6 kB
Tags Source
SHA-256 checksum
How to use checksums
97a935527a7a92e34d7be7c07d8ce43d614e71a208f3ca90786260bfbbd89149
BLAKE2b-256 checksum
How to use checksums
bc74fd8ebf8d5b6c40c5141ed72e68fd3be5160643c0b53a2cb32b3f79d5c0ff
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-26-generic

Release files / fedjust-0.1.2.5-py3-none-any.whl

Download URL fedjust-0.1.2.5-py3-none-any.whl
Size 19.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d76eeed7e8c079ee6dd2bad6a99f8643eaeba8eb9954a6e06e937e34cf01ec37
BLAKE2b-256 checksum
How to use checksums
98781ca7e43daf71303e9d8af31ce06317736e04f17cd765261b0d70599616ee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via poetry/1.7.1 CPython/3.10.12 Linux/6.5.0-26-generic

Security for FedJust 0.1.2.5

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page