# Application of Machine Learning to Assess the Quality of Food Products--Case Study: Coffee Bean
## 3 Results and Discussion
### The Design and Learning Process of Convolutional Networks  
While designing the CNN model, the architecture of the network was determined, with which it was possible to perform the intended task, i.e., the classification of coffee beans, taking into account the mentioned categorical classes. The CNN used a sequential model (Sequential model), with which the number of individual layers was determined. The advantage of the chosen model is its linear flow between layers in convolutional networks [52; 53]. Similarly, to the Multilayer Perceptron model, it is the most common and relatively simple type of neural model in machine learning [52], in which there is no feedback, and there is a relatively simple action for adding layers in the CNN structure. The designed Sequential model contained eight input layers, including four convolution and four MaxPooling layers, one global average layer and one output layer. The convolution window in the convolutional layers was shifted by two units instead of one, which resulted in a faster dimensionality reduction in large tensors in the network layers. After a series of convolution and reduction operations, the feature tensor was transformed to flat link to the dense layer for the final classifier [29; 54]. For the output layer, a sigmoid function was used, as it gave better results than the more commonly used softmax function in convolutional networks [39]. For the input layers, the Rectified Linear Unit (ReLU) function was used, which has emerged as the more effective activation function in this issue as in other studies [55]. This is due to the fact that the ReLU algorithm relative to other functions, including sigmoidal and hyperbolic tangent (tanh), prevents gradient from fading when learning convolutional models as well as other types of neural networks. In the problem of minimizing the loss function during model learning, the Adam algorithm was used with a loss minimization of 0.001. The Adam learning algorithm as well as others [56; 57], including RMSprop [58; 59], Adadelta and Nadam [60; 61], are based on performing network parameter updates [62]. The process of updating the network parameters is based on scaling by the square roots of the squares of the moving averages of the previously quoted gradient values at the point under study. These algorithms are constantly being improved by, among other things, giving them \"long-term memory\" against the gradient values that characterized the trained model in previous learning epochs [63]. The final step required determining model fit using epoch selection. The most efficient learning of the CNN model finally determined 55 epochs. The results of the learning are shown in Table 3.  
In the classification process of various research aspects based on bitmap images, the use of convolutional artificial neural networks made it possible to achieve a matching power coefficient in the range above 0.7. A matching power coefficient value below 0.7 would mean that there were discrepancies between the results of the designed convolutional networks and the pattern results for these networks (targets), i.e., they were not fully satisfactory at the specified stage of research. A quality matching coefficient of less than 0.6 would mean that the matching of the convolutional networks is insufficient for the CNNs \begin{table}
\begin{tabular}{c c c c c c c c c} \hline \hline \multirow{2}{*}{**Type**} & \multicolumn{3}{c}{**Testing Set**} & \multicolumn{3}{c}{**Training Set**} & \multirow{2}{*}{**Training**} \\ \cline{2-2} \cline{4-9}  & **MSE** & & & & & & & **Hidden** & **Algorithm** \\ \hline CNN & 0.1739 & 0.3238 & 0.8125 & 0.1941 & 0.3344 & 0.7312 & [PERSON] & [PERSON] \\ \hline \hline \end{tabular}
\end{table} 
Table 3: CNN’s learning results. to be able to independently decide coffee class recognition with sufficient accuracy. In Table 3, the model obtained was a CNN with a good fitting ability of R\({}^{2}\) = 0.81 (Figure 3a).