# TDLearning: Trusted Distributed Collaborative Learning Based on Blockchain Smart Contracts
## 5 Experiment and Case Study
### Model-Fusion Validation  
#### 5.2.1 Experimental Scenario Setup  
To aggregate the value of dispersed data resources, the collaborative-learning mechanism uses a model-fusion method based on feature fusion to achieve collaborative model training and proposes the use of an attention mechanism to precisely guide the model-fusion process. In order to verify the effectiveness of this mechanism for collaborative model training, a collaborative task based on the MNIST [35] dataset and the CIFAR10 [36] dataset is published by the task owner, and the global model classification accuracy is used as the evaluation index to analyse and evaluate the effectiveness of model fusion. The experiment set up one task owner and four task participants for a total of five collaboration nodes, with the collaboration goal of improving the global model accuracy. The structure of the pretrained model used by the collaborative nodes and the training parameters are shown in Table 6. Based on the differences in data distribution between collaborating nodes, the following three types of collaboration scenarios are experimentally set up to analyse the adaptability of the model-fusion approach to different data distributions. _Scenario A_: The data distribution in this scenario is shown in Table 7, with each node's local data being independently and identically distributed. _Scenario B_: The distribution of data in this scenario is shown in Table 8, where all four task participants had data samples from only some of the categories but the same amount of data from different labels. Figure 15: The execution results of status formula and query statement of Arbitration layer. Scenario C: In this scenario, the task owner has the same data as in the previous two scenarios, and the distribution of the task participants' data is shown in Figure 16. The horizontal axis in the figure represents the sample category, and the vertical axis represents the number of samples. Based on the above experimental scenario, the method proposed in [26] (F-Concat) is compared with the feature-fusion method based on the attention mechanism proposed in this paper (F-Attention). Meanwhile, the Federated Average Algorithm (FedAvg) in Federated Learning is introduced as a benchmark, and the five collaborating nodes in \begin{table}
\begin{tabular}{l l l} \hline \hline  & **CNN-MNIST** & **CNN-CIFAR10** \\ \hline Convolution layer 1 & 16 5 \(\times\) 5 kernels & 64 5 \(\times\) 5 kernels \\ Pooling layer 1 & 2 \(\times\) 2 max pooling & 2 \(\times\) 2 max pooling \\ Convolution layer 2 & 32 5 \(\times\) 5 kernels & 64 5 \(\times\) 5 kernels \\ Pooling layer 2 & 2 \(\times\) 2 max pooling & 2 \(\times\) 2 max pooling \\ Fully connected layer & 128 units (with ReLU activation) & 512 units (with ReLU activation) \\ Output layer & Softmax & Softmax \\ Optimiser & Adam & Adam \\ Learning rate & 0.001 & 0.001 \\ Batch size & 64 & 64 \\ Max local-training epochs & 20 & 20 \\ Max fine-tuning epochs & 20 & 20 \\ \hline \hline \end{tabular}
\end{table} 
Table 6: Pretrained model structure and training parameters. Figure 16: Data distribution in scenario C. \begin{table}
\begin{tabular}{l c c c c} \hline \hline
**Collaborative Nodes** & _To_ & _Tp_ **1** & _Tp_ **2** & _Tp_ **3** & _Tp_ **4** \\ \hline Amount & 1000/10,000 & 600/3000 & 600/3000 & 600/3000 \\ Label & & \(\{0,1,2,3,4,5,6,7,8,9\}\) & \(\{0,1,2,3,4,5,6,7,8,9\}\) & \\ \hline \hline \end{tabular}
\end{table} 
Table 7: Data distribution in scenario A (dataset: MNIST/CIFAR10). Federated Learning are trained with the following settings. In the MNIST dataset scenario, the number of local training rounds for the collaborative nodes is 20 and the maximum number of global model updates is 100, while in the CIFAR10 dataset scenario, the number of local training rounds for the collaborative nodes is 20 and the maximum number of global model updates is 50. In addition, the node-selection process is ignored in the global model update process, i.e., all nodes are selected to complete the global model update each time.