## 2 Methodology
### Deep Autoencoders: Latent Space Classification  
Autoencoders are unsupervised neural networks that can handle large amounts of data and can also be applied to reduce the dimension of input data, extracting their most important features. The simplest configuration of an autoencoder is based on an encoding layer and a decoding layer, as shown in Figure 3. By means of the encoder, the input data, \(\mathbf{x}\), are mapped into an arbitrary lower dimensional space, \(\mathbf{h}\). The decoder reconstructs the original data as an output \(\mathbf{\hat{x}}\) from h [18]. Therefore, the input and its  
Figure 2: Impedance spectrum: (**a**) initial and (**b**) normalized. corresponding output should be as identical as possible to each other. In this sense, the optimal autoencoder corresponds to the encoding-decoding scheme, keeping the maximum amount of information when encoding and providing a minimum reconstruction error of the input data when decoding. The transfer function of each module can be expressed as follows:  
\[Encoder\qquad\mathbf{h}=f(\mathbf{x})=\varphi(\mathbf{W}\mathbf{x}+\mathbf{b}) \tag{3a}\] \[Decoder\qquad\mathbf{\hat{x}}=g(\mathbf{h})=\varphi^{\prime}(\mathbf{W}\mathbf{h}+\mathbf{b}\prime) \tag{3b}\]  
where \((\mathbf{W},\mathbf{b})\) and \((\mathbf{W}^{\prime},\mathbf{b}^{\prime})\) are the weight matrices and bias vectors for encoder and decoder modules, respectively, while \(\varphi\) and \(\varphi^{\prime}\) are the activation functions of the encoder and decoder, respectively. Nonlinear activation functions, such as sigmoids or hyperbolic tangents, are usually applied. Training of the autoencoder consists of updating the learning parameters, \(\mathbf{W}\), \(\mathbf{W}^{\prime}\), \(\mathbf{b}\), and \(\mathbf{b}^{\prime}\), by minimizing an error or loss function defined between input \(\mathbf{x}\) and its reconstruction at the decoder's output, \(\mathbf{\hat{x}}\), which quantifies the error between both. The root mean squared error (RMSE), computed from the number of observations used for the training of the model, n, is frequently used for this purpose. \[RMSE=\sqrt{\sum_{i=1}^{n}\frac{\left(\mathbf{\hat{x}}_{i}-\mathbf{x}_{i}\right)^{2}}{n}} \tag{4}\]  
In the case of working with deep autoencoders, the encoding module is configured by a succession of layers with an increasingly smaller number of neurons, as if it were a bottleneck (Figure 4). This configuration allows for the progressive reduction in the dimension of the input neuron space, progressively extracting its most important features. The last layer of the encoder is the latent space, and it provides the most compressed representation of the input data. The effect of the decoder is to reconstruct the input neurons, in the most reliable way possible, through a series of layers in which the number of neurons increases, until it matches the dimension of the input space. Figure 3: Architecture of a single-layer autoencoder. Assuming N hidden layers for both the encoder and decoder, the encoding representation can be expressed as a generalization of Equation (3a) as follows:  
\[ \begin{split}\mathbf{h}^{(1)}=\varphi^{(1)}\Big{(}\mathbf{W}^{(1)}\mathbf{x}+ \mathbf{b}^{(1)}\Big{)}\\ \vdots\\ \mathbf{h}^{(N)}=\varphi^{(N)}\Big{(}\mathbf{W}^{(N)}\mathbf{h}^{(N-1)}+\mathbf{b} ^{(N)}\Big{)}\end{split}  \tag{5}\]  
where \(\mathbf{h}^{(i)}(1\leq i\leq N)\) is the encoded hidden representation, \((\mathbf{W}^{(i)},\mathbf{b}^{(i)})(1\leq i\leq N)\) represent the network's weights and biases, and \(\varphi^{(i)}(1\leq i\leq N)\) are the activation functions for the encoder. On the other hand, the decoding will reconstruct the input vector through the following transformation:  
\[ \begin{split}\mathbf{h}^{(N+1)}=\varphi^{(N+1)}\Big{(}\mathbf{W}^{(N+1)} \mathbf{h}^{(N)}+\mathbf{b}^{(N+1)}\Big{)}\\ \vdots\\ \mathbf{\hat{x}}=\varphi^{(2N)}\Big{(}\mathbf{W}^{(2N)}\mathbf{h}^{(2N-1)}+ \mathbf{b}^{(2N)}\Big{)}\end{split}