# Convolutional Neural Network for Measurement of Suspended Solids and Turbidity
## 2 Materials and Methods
### Experimental Setup
The AlexNet model (CNN) was taken from the Torchvision package, which offers some popular pre-trained models and other image processing tools. In artificial intelligence, the process of finding the \"best\" or \"optimal\" parameters for the performance of a CNN model is called optimization. The classic optimization  
Figure 5: Experimental setup: (**a**) scheme of the experimental setup; (**b**) experimental setup used. Figure 6: Recorded images of samples illuminated with a concentration of 0.1 gL\({}^{-1}\) of the fish feed mass in distilled water and under different lighting colors: (**a**) white light; (**b**) red; (**c**) blue; (**d**) green. Figure 7: The spectral power distributions of the RGB LED lamp used in this study: (**a**) blue; (**b**) green; (**c**) red; and (**d**) white. method is called stochastic gradient descent (SGD). It is a simple procedure that involves iteratively finding the values that result in the lowest possible error (loss) based on the training dataset. Although newer and more powerful optimization algorithms exist, SDG provides consistency in the overall training process and results. One of the most important hyperparameters is the \"learning rate\". It is responsible for adjusting the rate at which the model calculates the gradient of the loss function. Therefore, the learning rate controls how much the model changes its predictions as it updates its results based on model error. A high learning rate makes the model change its parameters quickly, while a low learning rate makes the model change its parameters slowly. The best option is the selection of a learning rate value that makes the error decrease correctly (not too quickly), finding the minimal error in the fewest number of epochs. An \"epoch\" is another relevant hyperparameter; it refers to the number of times that the entire training dataset is passed through the CNN model. However, a model is trained using batches. In the context of a single training epoch, \"batch size\" refers to the amount of data passed to be processed by the CNN and updates model parameters at a time until an epoch is complete. Larger batches allow for more computational parallelism, and can often lead to better performance. However, larger batches also require more memory and can cause latency when passed into the training function. Finally, the hyperparameter \"momentum\" is employed to accelerate the gradient descent by taking into account a fraction of the previous gradients to update to the current one. For the CNN training, the algorithm executed a total of 75 training epochs. The epoch number was selected by analyzing the loss of training according to previous executions of the training process. The CNN was trained using a stochastic gradient descent algorithm with a momentum of 0.9 and a batch size of 50. The other hyperparameters used in the experiment are listed in Table 2.  
The selection of the hyperparameters was established based on the image classification examples exposed in the PyTorch documentation. In addition, several executions were carried out in search of minimizing errors, and until a high accuracy of classification (100%) and estimation (98.24% and 97.20% for TSS and turbidity, respectively) was reached.