# Few-Shot Federated Learning: A Federated Learning Model for Small-Sample Scenarios
## 4 Model System
### Model Learning Process
In this section, the exponential function is chosen as the confidence discrepancy function, and the smoothing factor \(S\) is set to 2 to ensure sufficient sensitivity to the confidence discrepancy \(\Delta z_{x}\):

\[f(\Delta z_{x})=e^{\frac{\Delta z_{x}}{S}} \tag{16}\]

Moreover, a hyperparameter \(w_{i}\) is introduced into the system to facilitate the extraction of task-specific objectives. \[w_{i}=I(C_{i})=\left\{ \begin{matrix}0.9,(C_{x}\in C_{m})\cap(C_{x}\in C_{b}) \\ 0.1,C_{x}\
otin C_{m}\end{matrix} \right. \tag{17}\]

Consequently, this leads to the derivation of the final adaptive temperature parameter \(T_{i}\) and the ultimate loss function \(L_{KD}^{\prime}\):

\[T_{i}=1+w_{i}*(T_{max}-1)*\frac{f(\Delta z_{x})-1}{f(\Delta z_{x})+1} \tag{18}\]

The final loss function \(L_{KD}^{\prime}\) is obtained by substituting \(T_{i}\) into Equations (13) and (14), respectively. \[L_{KD}^{\prime}=-\sum_{C_{x}}w_{i}P_{c}(C_{x})\log P_{s}(C_{x}) \tag{19}\]

The design of this temperature parameter facilitates the confidence in sample classification based on the server-side model and the relevance to the client's local tasks. Ultimately, this achieves the effect of enabling clients to selectively extract parameters from the server-side model for knowledge distillation. The workflow is shown in Algorithm 2. ## 5 Experiment

### Datasets

This section of the experiment uses three datasets commonly utilized in the field of few-shot learning; these three datasets were selected because each category within them contains a small amount of data, and they are prone to forming non-IID data distribution patterns, making them highly suitable for evaluating the model proposed in this paper:

Omniglot [6], a dataset comprising images of handwritten characters from 1623 different character classes derived from alphabets of various natural languages around the world. Each class contains 20 distinct samples, with each original data sample being a single-channel image of 105 \(\times\) 105 pixels in size. FC100 [29], an image dataset based on the classic Cifar-100 dataset, consisting of 100 classes, each with 600 samples of 32 \(\times\) 32 resolution three-channel data. The dataset is further divided into train (60 classes), validation (20 classes), and test (20 classes) subsets. MinilmageNet [14], extracted directly from the ImageNet dataset, also comprises 100 classes, each with 600 samples of 84 \(\times\) 84 pixel size. Like the others, it is divided into train (64 classes), validation (16 classes), and test (20 classes) subsets. These datasets are integral to the research of few-shot learning, providing diverse challenges due to their varied class compositions and image resolutions. The structured division into training, validation, and test subsets facilitates a comprehensive evaluation of the learning algorithms under investigation, allowing for a balanced assessment of their generalization capabilities across different data distributions. ### Performance Evaluation

Classification accuracy is used as the evaluation metric in the model comparison experiments, with the accuracy formula presented as follows:

\[Acc=\frac{1}{|D_{test}|}\sum_{i=1}^{|D_{test}|}\frac{TP_{i}+TN_{i}}{TP_{i}+TN _{i}+FP_{i}+FN_{i}} \tag{20}\]

Here, \(|D_{test}|\) denotes the number of categories within the test dataset. TP (True Positives) refers to the count of positive instances correctly predicted as positive; TN (True Negatives) indicates the count of negative instances correctly predicted as negative; FP (False Positives) represents the number of negative instances incorrectly predicted as positive; and FN (False Negatives) denotes the number of positive instances incorrectly predicted as negative. In Section 5.3 of the experiments, we selected FedAvg as the representative algorithm for classical federated learning and FedFSL [30] as an advanced algorithm for small-sample federated learning to conduct comparative experiments.