# Fertility Detection of Hitching Eggs Based on a Convolutional Neural Network
## 3 Experiment and Results Analysis
### SR-CNN Experiment  
Knowing from the experiments of E-CNN that it is difficult for sequence convolution to extract features effectively from noisy signal which leads to intractability while training. Thus, we enhanced the dimension of the heartbeat signal by converting sequence into waveform, which is beneficial for SR-CNN to make full use of the waveform while extracting features. We conducted experiments on dataset DWI (original heartbeat signal waveform) and DWH (filtered heartbeat signal waveform). Before training, it was necessary to set the solution hyperparameter. The mini-batch sizewas set to 64, the momentum coefficient momentum was set to 0.9, the weight attenuation coefficient weight_decay was set to 0.0001 to prevent overfitting. The Stochastic Gradient Descent (SGD) was chosen to update weight. As for learning rate adjustment strategy, we selected the step strategy. The initial learning rate base_lr was set to 0.01, the learning rate change index gamma was set to 0.1, and the learning rate change step was set to 40 epochs (1 epoch represents all pictures of the training set is trained one time). The change formula of the learning rate during training is as follows:  
\[\text{lr}=\text{base\_lr}*\text{gamma}^{(\text{floor}(\frac{\text{iter}}{\text{ stepsize}}))} \tag{3}\]  
Different network architectures are compared to assess the rationality and feasibility of the network we designed. We discuss four different network architectures on our dataset DWH, with the mini-batch size is set to 64 during training. We designed a network architecture named Basic network, which is almost the same as SR-CNN except without using the SE module and \"short connection\". Another two networks are designed based on Basic network by adding the SE module and the \"short connection\" respectively. We selected 200 epochs during network training and compared the changes of accuracy and loss; the results are shown in Figure 11.  
During the network training, the generated model was assessed on the validation set, and the model as evaluated as the best was saved. In the period of the test, the saved optimal model was selected to test the heartbeat waveform  
the model's comprehensive performance. We tested different models on the dataset DWH; the test set sample distribution is shown in Table 5.  
The fertile eggs are defined as positive samples, and the dead eggs are defined as a negative samples. In the test, the number of fertile eggs detected correctly in the samples is defined as TP, and the number of fertile eggs detected falsely is defined as FN. The number of dead eggs detected correctly in the sample is defined as TN, and the number of dead eggs detected as fertile eggs is defined as FP. We the calculated Accuracy, Precision, Recall and F1 scores according to formula (4). \[\left\{ \begin{array}{l}\text{Accuracy}=\frac{\text{TP}+\text{IN}}{\text{ TP}+\text{IN}+\text{FP}+\text{FN}}\\ \text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}}\\ \text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FP}}\\ \text{F1}=\frac{2*\text{Precision}*\text{Recall}}{\text{Precision}+\text{Recall}} \end{array} \right. \tag{4}\]  
It can be seen from Table 6 that the network model designed in this paper has the best performance on the test set compared with other network models due to the combination of the SE module and the residual block. The model trained by network SR-CNN has the lowest false detection rate and the highest detection accuracy. The Recall and F1 scores are higher than on the other models, which indicates the feasibility and superiority of the SR-CNN network model designed in this paper. The SE module models the nonlinear dependence relationship of feature channels by recalibrating the importance of each feature channel, which simplifies the learning process and enhances the network expression ability. The SE module reduces the dimension of the global features to the original 1/R by the stimulus operation, and then reverts to the previous dimension after being activated by the Relu function.