# Snack Texture Estimation System Using a Simple Equipment and Neural Network Model +
## 4 Neural Network Model  
The neural network model for texture degree estimation is shown in Figure 10. The input layer comprises 10 nodes for W1-W5 and F1-F5, and a bias node. Hidden layers 1 and 2 comprise 10 nodes and a bias node, respectively. The output layer comprises two nodes expressing the degree range (0,1) of \"crunchiness\" and \"crispness\". The transfer function of hidden layers 1, 2, and the output layer is expressed in Equations (1)-(3), respectively, where \(x_{j}\) is \(j\)-th input node value, \(H_{k}\) is the output value of \(k\)-th node of hidden layer 1, \(I_{\ell}\) is the output value of the \(\ell\)-th node of hidden layer 2, and \(Y_{1}\) and \(Y_{2}\) are the model outputs:  
\[H_{k}=\frac{1}{1+\exp(-z_{k})},\;z_{k}=\sum_{j=0}^{10}x_{j}w_{jk},\;x_{0}=1.0 \tag{1}\]  
\[I_{\ell}=\frac{1}{1+\exp(-s_{\ell})},\;s_{\ell}=\sum_{k=0}^{10}H_{k}v_{k\ell}, \;H_{0}=1.0 \tag{2}\]  
\[Y_{m}=\frac{1}{1+\exp(-p_{m})},\;p_{m}=\sum_{\ell=0}^{10}I_{\ell}u_{\ell m},\; I_{0}=1.0 \tag{3}\]  
where \(w\), \(v\) and \(u\) are the connection weights between the input layer and hidden layer 1, between hidden layers 1 and 2, and between hidden layer 2 and the output layer, respectively. The connection weights were adjusted to minimize the difference (i.e., error) between the expected value and the actual neural network output \(Y_{m}\) via the back-propagation algorithm [22]. For a limited amount of data, such as in our case, the neural network model is verified via cross-validation [23]. We implemented the leave-one-out cross-validation (Figure 11) normally adopted for obtaining a reliable estimation [24]. Figure 10: A neural network model for estimating food texture. For Data Set (1), initially, (W1-W5, F1-F5) of sample Nos. 2-1000 were used for training the connection weights of the neural network in step (A). Subsequently, (W1-W5, F1-F5) of No. 1 were inputted to the trained network in step (B). Finally, crunchiness and crispness outputs of the network were registered in the estimation result data store in step (C). Similarly, (A)-(C) were repeated from Data Sets (2)-(1000). This _Leave-One-Out Cross-Validation (LOOCV)_ was thus considered as 1000-fold cross-validation. The above procedure could be explained as follows:  
**Step 0**: \(i\gets 1\)  
**Step 1**: Select \(i\)-th sample data out of all 1000 samples  
**Step 2**: Prepare the next 999 train input vectors except the \(i\)-th data  
\[X_{train}^{(n)}=\left[ \begin{array}{c}W_{1}^{(n)}\\ \vdots\\ W_{5}^{(n)}\\ F_{1}^{(n)}\\ \vdots\\ F_{5}^{(n)}\end{array} \right]\text{ for }n=1,\;2,\cdots,\;999.\]  
**Step 3**: Prepare the next 999 correct output vectors  
\[Y_{train}^{(n)}=\left[ \begin{array}{c}Y_{1}^{(n)}\\ Y_{2}^{(n)}\end{array} \right]\text{ for }n=1,\;2,\cdots,\;999.\]  
Figure 11: Schematic of the leave-one-out cross-validation. where, \(Y_{train}^{(n)}=\left[ \begin{array}{c}0.9\\ 0.8\end{array} \right]\) is assigned for the rice crackers, \(Y_{train}^{(n)}=\left[ \begin{array}{c}0.2\\ 0.9\end{array} \right]\) is assigned for the potato chips, \(Y_{train}^{(n)}=\left[ \begin{array}{c}0.7\\ 0.7\end{array} \right]\) is assigned for the cookies, \(Y_{train}^{(n)}=\left[ \begin{array}{c}0.5\\ 0.7\end{array} \right]\) is assigned for the biscuits, and \(Y_{train}^{(n)}=\left[ \begin{array}{c}0.4\\ 0.8\end{array} \right]\) is assigned for the corn snacks. These values were in accordance with Table 1.  
**Step 4**: Initiate the connection weights \(w\), \(v\), and \(u\), which are random values. Train the neural network model by the back-propagation algorithm by adjusting \(w\), \(v\), and \(u\) so that \(Y_{train}^{(n)}\) is outputted when the corresponding \(X_{train}^{(n)}\) is inputted. In particular, the iteration to train the network is 100 epochs. It is necessary to observe the decreasing error as the epoch proceeds. **Step 5**: Input W1-W5 and F1-F5 of the \(i\)-th sample data into the neural network model trained in previous step i.e., **Step 4**. (\"Note that the \(i\)-th sample data is not used to train the neural network in **Step 4**.)