# Project Composition

### Three types of nodes

Fiesta project is an instance of **federated learning applied on spectrum data**. Just like vanilla federated learning, <mark style="color:blue;">**edge nodes**</mark> first collect data by themselves and perform machine learning. After training with local data, edge nodes will upload trained model, instead of raw data, to the <mark style="color:orange;">**average server**</mark>. Average server will gather all received local models and generate a new global model for the next round local training.&#x20;

In the context of Fiesta project, our <mark style="color:blue;">**edge nodes**</mark> are actually <mark style="color:blue;">**mobile devices**</mark> connected with a compatible SDR sampling board. The board will sample spectrum data and send it to android device. With Fiesta Android Client installed, this mobile device can perform federated learning with no extra efforts.

For Fiesta project, we did not use a single <mark style="color:orange;">**average server**</mark>. As a substitution, we adopt a cluster of <mark style="color:orange;">**miner nodes**</mark>. Each miner nodes will do the almost the same thing as an average server in terms of model weights integration. However miners will share and record those local models in a blockchain manner, just like distributed ledger.&#x20;

In this case, the system becomes much **more robust to node failures as well as network failures** compared with a centralized server. Additionally, transparent and immutable records of each member's contribution makes **a fair incentive mechanism** practicable, which is the key for maintaining a crowdsourcing ecosystem.

Besides <mark style="color:blue;">**mobile devices**</mark> and <mark style="color:orange;">**miner nodes**</mark>, an extra type of node, <mark style="color:green;">**seed node**</mark>, is introduced to sustain the connection between participants of Fiesta project, who is pretty similar to tracker server in BitTorrent protocol. It tracks available miners in the system and responses to requests from miners and mobile devices.

{% hint style="info" %}
Mobile device has no idea about the blockchain among the miner network. It just downloads, trains, and uploads like normal edge node in the federated learning.
{% endhint %}

### One big cycle

![Ecosystem of Fiesta project](https://2975126063-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FViUbht1bKEX2BS76RQe2%2Fuploads%2FROvCHrgMV702INAgX1TK%2Feco.png?alt=media\&token=06eb4de2-161d-4d11-983f-3673abe86a62)

One cycle of model training in Fiesta will be as follows:

* **Seed node** injects primitive model and training parameters into **miner** network
* **Mobile device** fetches the list of those online miners from **seed node**
* **Mobile device** fetches the latest global model from any **miner**
* **Mobile device** trains model locally with local dataset
* **Mobile device** sends trained local model to any **miner**, a miner will also share its received local model with peers.
* **Miner** gathers received local models into one new global model

Besides the normal training cycle, **seed node** also plays a role in node registration and reward stats.

* **Seed node** fetches the stable chain from **miner** network and calculate everyone's contribution periodically.
* Each **Miner** needs to register itself to **seed node** from time to time to make itself popular

{% hint style="success" %}
Everyone can have easy access to the trained model at any time, which is our goal of crowdsourcing spectrum sensing. Just visit the corresponded API of miners.
{% endhint %}
