# Data Compression Based on Stacked RBM-AE Model for Wireless Sensor Networks
## 3 Results and Discussion
### Compression and Reconstruction  
We used the following performance criteria to evaluate the performance of our compression algorithm: (1) compression ratio (\(CR\)); (2) percentage RMS difference (\(PRD\)) [26]; (3) quality-score (\(QS\)) [26]. The definitions and formulas of these performance criteria are as follows:  
(1) Compression Ratio (\(CR\)): It is defined as the compressed data length over the size of uncompressed data, as shown in Equation (15). \[CR=\frac{D_{or}}{D_{cp}} \tag{15}\]  
where \(D_{or}\) is the number of bytes of all original data. \(D_{cp}\) is the number of bytes of all compressed data. The \(CR\) value is expected to be high for an effective compression algorithm. (2) Percentage RMS Difference (\(PRD\)): It is a widely used performance measure that is used for calculating the quality of reconstructed data in the compression. The \(PRD\) value is expected to be as low as possible for a quality compression approach. \[PRD(\%)=100\times\left(\frac{\sum_{i=0}^{D-1}\left(S_{o}(i)-S_{r}(i)\right)^ {2}}{\sum_{i=0}^{D-1}\left(S_{o}(i)\right)^{2}}\right)^{1/2} \tag{16}\]  
where \(S_{o}\) represents the original input data, \(S_{r}\) represents the reconstructed data. (3) Quality-Score (\(QS\)): Other important evaluation criteria for determining the effectiveness of compression algorithms is the \(QS\) value. \(QS\) is the ratio of \(CR\) to \(PRD\). It represents the reconstructed data quality. The larger the \(QS\) value, the better the compression and reconstruction performance. \[QS=\frac{CR}{PRD} \tag{17}\]  
The learning rate determines how far the weights move in the gradient direction in a mini-batch, which is usually set by the experimenter. If the learning rate is small, the training will become more reliable, but optimization will take a long time, because each step towards the minimum of the loss function is small. If the learning rate is big, the training may not converge and could also diverge. Optimization will cross the minimum value and cause loss function to become worse. There are many ways to set an initial value for the learning rate. A simple solution is to try a few different values to see which value will optimize the loss function without loss in training speed. In the pre-training phase, we refer to the parameters in Ref. [36], set the learning rate of 0.01/batch-size (the batch-size is 120). In the retraining phase, we start with a value of 0.1, then exponentially reduce the learning rate to 0.01, 0.001 and 0.0001. In order to find the optimal learning rate, we set different learning rates to train the model and record the summation of loss value when the model loss is no longer reduced [37]. Figure 5 shows the loss value of a model with different learning rates. We sought to find a point with the smallest value of model loss. In our experiment, we found that when the learning rate was between 0.0001 and 0.001, the model loss value was the smallest. We finally selected a learning rate of 0.0001. We first use the training set of node 7 to pre-train the model without retraining, and test the efficiency of a different number of pre-training iterations to the compression performance of the model. Then we use the test set of node 7 to calculate the _PRD_ value and the _QS_ value of the model under different numbers of pre-training iterations. Similarly, we use the training set of node 7 to retrain the model with a fixed number of pre-training iterations. We use the test set of node 7 to calculate the _PRD_ value and the _QS_ value of the model under different numbers of retraining iterations. During the test, we added the _PRD_ value and the _QS_ value of each mini-batch of the test set, and then averaged the sum value as the final result. The number of mini-batches of the test set is 325. The results are shown in Figure 6.  
Without retraining, the compression performance of the model will not increase and could even decrease with an increase in the number of pre-training iterations.