# Low-Complexity Microclimate Classification in Smart Greenhouses: A Fuzzy-Neural Approach
## 3 Feed-Forward Neural Network Theoretical Background  
In our work, we employ a FFNN as the base architecture. This choice is motivated by its ability to adapt parameters to changing environmental conditions, making it a low-complexity starting point for microclimate monitoring applications in GHs [33]. In this section, we present the theoretical background on its functioning and architectural complexity. Typically, an FFNN consists of an input layer, a certain number (\(M\)) of hidden layers, and an output layer. All neurons in the network are fully connected by the neurons in both the preceding and succeeding layers. In our methodology, to identify the optimal architecture for our purpose, we vary the number of neurons in both the input and hidden layers. As commonly adopted, in this work, the Levenberg-Marquardt method is employed as the training algorithm. Specifically, the algorithm begins with an initialization phase in which an initial estimate of the network weights is made, and the damping parameter (\(\mu\)) is set, in our case to 0.001, a commonly used value [34]. The network then produces an output, and the error (e) is computed by subtracting the predicted output from the actual output, with the objective of minimizing the sum of squared errors. Subsequently, the Jacobian matrix (\(J\)) is calculated, containing the partial derivatives of the errors with respect to the weights. The weights are then updated according to the following equation:  
\[\Delta\mathbf{w}=-(J^{T}J+\mu I)^{-1}J^{T}\mathbf{e}. \tag{1}\]  
If the error after the weight update decreases, the update is accepted and \(\mu\) is decreased. Conversely, if the error increases, the update is rejected and \(\mu\) is increased in order to make the next update more conservative. These steps are repeated until the variation in error becomes smaller than a predefined threshold, set to \(10^{-6}\), or until a maximum number of epochs is reached, set to 1000. Figure 1 illustrates the NN architecture, emphasizing the computational steps of a single neuron. The inference phase consists of propagating input data through the network, where each neuron computes the weighted sum of its inputs and bias, concluding with an activation function. The typical activation functions used include Sigmoid, ReLU, tanh, and Swish [35]. In our case, as we are addressing a classification problem, we utilize the Sigmoid function, as discussed in Section 4. More specifically, Equation (2) defines the computational steps of each neuron in the NN:  
\[ \begin{split}& Z=b+\sum_{k=1}^{I}X_{k}W_{k},\\ & y=\sigma(Z)=\sigma\left(b+\sum_{k=1}^{I}X_{k}W_{k}\right), \end{split}  \tag{2}\]  
Figure 1: FFNN-node computations. where \(W\) represents the weight values, \(X\) denotes the neuron inputs, \(b\) is the neuron bias, \(\sigma()\) is the activation function, and \(I\) is the number of inputs to the node. Regarding the backpropagation phase, we employ the approach based on MSE. Accordingly, it is utilized in computing the gradient of the loss function concerning the network's weights and biases. Beyond analyzing prediction performance metrics, it is essential to jointly consider the architectural complexity when selecting the NN architecture. In particular, the number of variables allocated in memory (Var) and the number of floating-point operations (FLOPs) required for inference should be considered, as defined in Equations (3) and (4), respectively. \[\text{Var}= \begin{cases}n_{i}n_{h,1}+n_{h,1}n_{o}+n_{h,1}+n_{o},&\text{if }M=1,\\ n_{i}n_{h,1}+\sum\limits_{j=1}^{M-1}(n_{h,j}n_{h,j+1})+n_{h,M}n_{o}+\sum\limits _{j=1}^{M}n_{h,j}+n_{o},&\text{if }M>1.\end{cases}  \tag{3}\]  
\[\text{Flops}= \begin{cases}2\,n_{i}\cdot n_{h,1}+n_{h,1}+2\,n_{h,1}\cdot n_{o} +n_{o}+F_{a}\,(n_{o}+n_{h,1}),&\text{if }M=1,\\ 2\,n_{i}\cdot n_{h,1}+n_{h,1}+\sum\limits_{j=1}^{M-1}(2\,n_{h,j}\cdot n_{h,j+1} +n_{h,j+1})+\\ +2\,n_{h,M}\cdot n_{o}+n_{o}+F_{a}\,(n_{o}+\sum\limits_{j=1}^{M}n_{h,j}), \end{cases}