# Biomedical Image Classification via Dynamically Early Stopped Artificial Neural Network
###### Abstract  
It is well known that biomedical imaging analysis plays a crucial role in the healthcare sector and produces a huge quantity of data. These data can be exploited to study diseases and their evolution in a deeper way or to predict their onsets. In particular, image classification represents one of the main problems in the biomedical imaging context. Due to the data complexity, biomedical image classification can be carried out by trainable mathematical models, such as artificial neural networks. When employing a neural network, one of the main challenges is to determine the optimal duration of the training phase to achieve the best performance. This paper introduces a new adaptive early stopping technique to set the optimal training time based on dynamic selection strategies to fix the learning rate and the mini-batch size of the stochastic gradient method exploited as the optimizer. The numerical experiments, carried out on different artificial neural networks for image classification, show that the developed adaptive early stopping procedure leads to the same literature performance while finalizing the training in fewer epochs. The numerical examples have been performed on the CIFAR100 dataset and on two distinct MedMNIST2D datasets which are the large-scale lightweight benchmark for biomedical image classification. image classification; biomedical imaging; early stopping; artificial neural network; GreenAI; health care; machine learning in healthcare +
Footnote †: journal:  
0000-0001-9993-3300-3300]M. A.  
where \(F\) is the so-called loss function and it computes the difference between the actual ground-truth and predicted values, \(n\) is the cardinality of the training set and \(d\) is the number of features. Each \(f_{i}:\mathbb{R}^{d}\rightarrow\mathbb{R}\) denotes the loss function related to the \(i\)-th instance of the training set. Because \(n\) can be a very large number, it is prohibitively expensive to compute all the terms of the objective function \(F(x)\) or its gradient. Moreover, the whole dataset may be too large to be completely stored in memory. Finally, in the online learning setting, where the dataset is not available from the beginning in its completeness but is acquired during the learning process, it is impossible to work with \(F(x)\). In all these cases, the minimization problem is faced by exploiting stochastic approximations of the gradient that lead to the use of stochastic gradient (SG) methods [1]. Given at each iteration \(k\) a sample \(\mathcal{S}_{k}\) of size \(n_{k}<<n\) randomly and uniformly chosen from \(\mathcal{N}=\{1,\ldots,n\}\), the SG algorithm to solve problem (1) can be written as  
\[x_{k+1}=x_{k}-\eta_{k}g(x_{k}) \tag{2}\]  
where \(\eta_{k}\) is a positive parameter called the _learning rate_ (LR) and the stochastic direction \(g(x_{k})\) is computed as  
\[g(x_{k}):=\frac{1}{n_{k}}\sum_{i\in\mathcal{S}_{k}}\
abla f_{i}(x_{k}).\]  
The sample \(\mathcal{S}_{k}\) is the _mini-batch_ at the \(k\)-th iteration and its cardinality \(n_{k}\) is the mini-batch size (MBS). In order to accelerate the convergence rate of the SG method, a _momentum_ term [2] can be added to the iteration (2). In more detail, chosen \(\beta\in[0,1)\) and setting \(m_{0}=0\), the momentum version of the SG scheme has the following form:  
\[\left\{ \begin{aligned} m_{k+1}&=\beta m_{k}+g(x_{k}) \\ x_{k+1}&=x_{k}-\eta_{k}m_{k+1}\end{aligned} \right. \tag{3}\]  
where \(\eta_{k}\) is the positive LR. In general, to design efficient and accurate ML or DL methodologies, it is needed to properly set the hyperparameters connected to the algorithm chosen for the training phase, particularly the LR and the MBS. We define the hyperparameters of a learning method as those parameters which are not trained during the learning process but are set a priori as the input data. In the literature, there are different philosophies to approach the problem of setting the hyperparameters.