# Prediction of Soluble Solids Content in Green Plum by Using a Sparse Autoencoder
## 3 Model Establishment  
### Sae  
The autoencoder, which is usually used for the pretraining of the original high-dimensional data to reduce the data dimension and remove some useless information, is an unsupervised model of artificial intelligence deep learning [23; 24]. This model can reduce the subsequent training pressure of the model and improve training accuracy. The autoencoder included an encoder and a decoder. The autoencoder was used to reconstruct the input data at the output layer and ensure that the output signals [X\({}_{1}\)', X\({}_{2}\)', X\({}_{3}\)',..., X\({}_{n}\)'] were exactly the same as the input signals [X\({}_{1}\), X\({}_{2}\), X\({}_{3}\),..., X\({}_{n}\)]. The encoding and the decoding processes of the autoencoder are defined as:  
\[h=f_{e}(W_{1}x+b_{1}) \tag{2}\]  
\[x^{\prime}=f_{d}(W_{2}h+b_{2}) \tag{3}\]  
where \(h\) is the encoded hidden layer feature parameter; \(W_{1}\) and \(b_{1}\) are the weight and the offset, respectively, of the encoder; \(W_{2}\) and \(b_{2}\) are the weight and the offset, respectively, of the decoder; \(f_{e}\) and \(f_{d}\) are the activation functions of the encoder and the decoder, respectively. The commonly used activation functions are sigmoid, tanh, and Relu. The definition of the loss function of the autoencoder is given to minimize the difference between the input and output data of the autoencoder. \[J(W,b)=\frac{1}{2n}\sum_{i=1}^{n}\|x_{i}^{\prime}-x_{i}\|^{2} \tag{4}\]  
where \(n\) is the number of input samples, \(x_{i}\) and \(x_{i}^{\prime}\) represent the input and the output, respectively, of sample \(i\). The output of the autoencoder was almost equal to the input. However, the intermediate hidden layer obtained by encoding the input layer can restore the original features after decoding. Therefore, the hidden layer implemented the abstraction of the raw data. The abstraction was another way to represent raw data. When the number of neurons in hidden layer was greater than or equal to the dimension of the input layer, the data were embedded in the neural network mechanically, and features were not extracted. When the number of neurons in the hidden layer was less than the dimension of the input layer, autoencoding can extract the features. Therefore, on the basis of traditional autoencoders, the sparsity restriction was added to the hidden layer neurons to form the SAEs [25; 26]. Figure 4 shows the structure of the SAE. Most neurons of the hidden layer in the SAE were restricted, presented as H\({}_{1}\) and H\({}_{m}\) in Figure 4.  
Figure 3: Original spectral reflectance curve of plum samples. The sigmoid is an example of an activation function. A neuron was activated when its output was close to 1 and suppressed when its output was close to 0. The sparsity parameter \(\rho\) was introduced to suppress the neuron activity. \(\rho\) was adopted close to 0 to make the average activation degree of the hidden layer neurons \(\hat{\rho}_{j}\) equal to \(\rho\) as much as possible. The sparsity restriction was added to the original autoencoder as an additional penalty factor. \[\sum_{j=1}^{s}\rho\log\frac{\rho}{\hat{\rho}_{j}}+(1-\rho)\log\frac{1-\rho}{1- \hat{\rho}_{j}} \tag{5}\]  
where \(j\) stands for each neuron in the hidden layer, \(s\) is the number of hidden layer neurons, \(\hat{\rho}_{j}\) is the average activation degree of hidden layer neurons, and \(\rho\) is a sparsity parameter. After adding the sparsity restriction to the SAE, the cost function is defined as:  
\[J_{sparse}(W,b)=\frac{1}{2\pi}\sum_{i=1}^{n}\|x_{i}^{\prime}-x_{i}\|^{2}+\beta \left(\sum_{j=1}^{s}\rho\log\frac{\rho}{\hat{\rho}_{j}}+(1-\rho)\log\frac{1- \rho}{1-\hat{\rho}_{j}}\right) \tag{6}\]  
where \(\beta\) is the weight of the sparsity penalty factor. The sparsity restriction made most of the neurons in the hidden layer restricted. Therefore, the encoding process of the SAE extracted the low-dimensional feature vectors from the high-dimensional data.