# Enhanced Privacy-Preserving Architecture for Fundus Disease Diagnosis with Federated Learning
## 3 Methodology
### Proposed DataWeighted Fed Approach
#### 3.5.2 Proof  
The study proposes a novel collaborative FL architecture found in Figure 5.  
As shown in Figure 5, the architecture contains an arbitrary number of clients \(m\). Each client houses their dataset (private, PI data compiled independently) and a local model. All models used in this study leverage TL with the VGG-19 model. The novelty of this study's  
Figure 5: Proposed FL architecture. proposed architecture comprises two main components: \(k\)-client selection training and the _wFedAvg_ (custom, dynamically weighted _FedAvg_) client model aggregation method. In any FL environment, the clients are collectively working together to train a global model. This means all clients have the same end goal, with all clients contributing their datasets, consisting of data from the same feature space. This study's feature space comprises fundus images; however, each client has different data samples, making each client's data considered non-IID. The proposed architecture can increase training speed and reduce the required computations by leveraging this. This is especially beneficial because FL environments primarily involve many clients, so many resources must be expended, and many resources must be spent to train these models collectively--before they aggregate together for the global model. Therefore, this study randomly selected \(k\) clients to train locally for \(n\) epochs in each round of FL (\(n\) and \(k\) are hyperparameters, where \(n=1\) and \(k=2\)). This can be performed because the data from each client are from the same feature space, so model training is consistent and comparable across all clients. Thus, the aggregated global model will also capture shared patterns across all clients because the k clients are selected randomly. The principle can be translated into a formulaic representation, as shown below. Let \(G_{t}\) be a global model at round \(t\), \(C\) the total number of clients, \(k\) the number of randomly selected clients per round, \(n\) the number of local training epochs per round, \(D_{i}\) the dataset of client \(i\), \(w_{i}{}^{(t)}\) the local model weights for client \(i\) at round \(t\), \(\eta_{i}\) the contribution weight of client \(i\) to the aggregation (based on dataset size). The FL process for each round \(t\) can be expressed as:  
1. _Client Selection_: \[S_{t}\subseteq\{1,2,\ldots,C\},\,|S_{t}|=k,\] (1)  
where \(S_{t}\) is the subset of \(k\) randomly selected clients for round \(t\). 2. _Local Training for Selected Clients_: each selected client \(i\in S_{t}\) updates its local model by minimizing its local loss function over \(n\) epochs: \[w_{i}{}^{(t)}=\textit{Train}(G_{t-1},\,D_{i},\,n)\] (2) where _Train_ is the local training procedure using the client's data \(D_{i}\). 3. _Global Aggregation_: the global model \(G_{t}\) is updated as a weighted average of the local models: \[G_{t}=\sum\eta_{i}\times w_{i}{}^{(t)}\text{ with }i\in S_{t}\] (3) where \(\eta_{i}=|D_{i}|/(\sum|D_{i}|)\) with \(j\in S_{t}\), the aggregation is proportional to dataset sizes. In the proposed simplified example, since \(n=1\) and \(k=2\), each client trains locally for only one epoch; two clients are randomly selected per round, and consistent feature space guarantees efficient FL training and aggregation. The most popular model aggregation method in the FL space is _FedAvg_[36]. _FedAvg_ takes the average of local model weights and updates the global model with that average for each round of FL. However, _FedAvg_ is prone to drawbacks, especially if there is data distribution heterogeneity between devices (e.g., differently sized datasets per client). In that case, _FedAvg_ does not consider the amount of data in each local model and cannot weight each result's effect on the global model based on the data distribution proportions. Therefore, this study aimed to address _FedAvg_'s drawbacks by developing and using a custom, dynamically weighted _FedAvg_ aggregation method (_wFedAvg_).