# Resource-Aware ECG Classification with Heterogeneous Models in Federated Learning
## 3 Materials and Methods
### HeteroFL Framework for ECG Classification  
The heterogeneous FL framework \"HeteroFL\" [12] is designed to enable heterogeneous ECG clients with varying computational power to train models of different capabilities. To emulate diverse resource-aware ECG clients, each client's computational complexity level, \(p\), is defined, and the global model's output channel is shrunk according to the computational complexity level of each client. Figure 3 illustrates the distribution of five local clients connected to the global model, \(W_{g}^{0}\), based on three computational complexity levels. This framework consists of a global model on the server connected to five clients, each assigned one of the three computational complexity levels. Levels \(L^{1}\), \(L^{2}\), and \(L^{3}\) represent the three complexity levels assigned to the five clients. \(L^{1}\) retains all the parameters of the global model, while \(L^{2}\) and \(L^{3}\) retain 75% and 50% of the output channels of the global model, respectively. After the local models are created, the server assigns them to the clients. The clients then train their data according to the assigned model. ECG clients with higher computational power train larger model instances, while clients with lower computational power receive shrunk versions of the model. After each training round, clients transmit their updated model parameters (instead of raw data) to the central server, where an aggregation mechanism integrates these updates by integrating the averaged updated parameters into the global model. This iterative process ensures that heterogeneous ECG clients contribute effectively to the training process while benefiting from a collectively refined global model. Figure 2: Architecture of the 1D CNN model used for ECG classification. The entire process is outlined in the following steps. First, the global model \(W_{g}^{0}\) is initialized at the server, and width slimming is applied to compress the global model with predetermined compression ratios. The model is scaled using the channel shrinkage ratio \(r\), reducing its input and output dimensions as follows:  
\[d_{lp}=r^{p-1}d_{g},\quad k_{lp}=r^{p-1}k_{g} \tag{1}\]  
where \(d_{lp}\) and \(k_{lp}\) are the output and input channels at complexity level \(p\), \(d_{g}\) and \(k_{g}\) are the corresponding global model dimensions, and \(r\) is the shrinkage ratio. The total parameter count of each local model is as follows:  
\[W_{l}^{p}=r^{2(p-1)}W_{g}^{0} \tag{2}\]  
Thus, both the input and output channels scale by \(r^{p-1}\), and the total parameters scale quadratically (\(r^{2(p-1)}\)), ensuring a balanced trade-off between efficiency and model expressiveness. Each client is assigned a model variant based on its available computing resources. Clients with higher computational power receive a larger model instance, while resource-constrained clients are assigned a compressed version with a reduced number of parameters. This ensures that all clients can participate in training while maintaining efficiency based on their capabilities. In each communication round, \(t\), a subset of active clients, \(m\), is selected from the local client pool \(M\) to participate in training. Each client trains its assigned model variant using local ECG data through batch-based optimization to minimize a loss function specific to ECG classification. After training, the updated model parameters are transmitted to the central server. The server aggregates the local model updates, ensuring that each subnetwork's updates are properly aligned with the global model structure. The aggregation process follows a weighted averaging approach to effectively integrate the contributions from different clients. \[W_{g}^{l}=1/m\sum_{i=1}^{m}W_{l}^{p} \tag{3}\]  
Figure 3: HeteroFL framework for ECG classification.