# Emotion Recognition from Speech in a Subject-Independent Approach
## 5 Methods
### Applied Classification Methods
Then, a softmax layer transforms the output from the fully connected layer into a probability distribution, a typical approach in classification, allowing the output to be interpreted as the probability of belonging to particular classes [69]. The Adam optimization algorithm is used to update the model's weights, a commonly recognized choice for its efficiency and convergence speed in various tasks [70]. The data are shuffled before each epoch, helping prevent overfitting by ensuring the model does not learn irrelevant details of a specific order of training data. For training the LSTM network, two groups of audio signal features were used: mel-frequency cepstral coefficients--12 coefficients and pitch (fundamental frequency). Other features that form sequences (energy and spectral features) were also experimented with, but their application did not improve classification results. Convolutional neural networks can also be successfully applied to the analysis of audio data [71]. They reduce data dimensionality while preserving key information essential for emotion classification. CNNs are also less sensitive to shifts and deformations in the input data, which is vital in sound analysis where emotions can be expressed differently by various speakers. This resistance to variability in data makes CNNs more versatile and adaptive compared to other classification methods. Finally, the ability of CNNs to learn a hierarchy of features--from simple to increasingly complex--makes them exceptionally good at capturing the emotional complexity contained in the human voice. This allows for a deep understanding and interpretation of subtle acoustic signals that differentiate emotions. In our research, we utilized CNNs for processing calculated features arranged in a vector (1D CNN) and, in the next step, for processing images--spectrograms (2D CNN). The first case, the 1D CNN, begins with an input layer sized 96 \(\times\) 1. Then, data flows through two 1D convolutional layers with filters sized 96 \(\times\) 1 and 16 \(\times\) 1 for the first layer and 16 \(\times\) 1 and 32 \(\times\) 1 for the second, where both are set with 'padding' to'same'. This means that zeros are added around the input feature maps so that the output has the same height and width as the input. This helps preserve spatial information and simplifies the design of deeper networks. Each convolutional layer is connected to a batch normalization layer, which helps stabilize the learning process by normalizing the output from the preceding layer, and a ReLU activation layer. At the end of the architecture is a fully connected layer with 8 neurons, aimed at aggregating features into a form that enables classification, followed by a softmax layer, transforming the results into a probability distribution of belonging to specific classes. The training of the model is conducted using the Adam optimizer. An initial learning rate set at 0.001 and a maximum number of epochs at 50 allow for gradual adjustment of the model weights in the learning process. A convolutional neural network (2D CNN) is then used for processing images --spectrograms. The first layer of the 2D CNN network accepts images in the form of spectrograms. The spectrograms are preprocessed into grayscale. Subsequently, three sets of layers consisting of a 2D convolutional layer, a ReLU layer, and a normalization layer are applied. The first convolutional layer has 3 \(\times\) 3 filters, with 'padding' set to'same', meaning that the convolution output will have the same size as its input. After each set of convolutional layers, a 2D maxPooling layer is applied, which reduces spatial dimensions by selecting the maximum value from a 2 \(\times\) 2-pixel square. This is followed by two more convolutional layers with a larger number of filters (16 and 32, respectively), also with ReLU activation and normalization, and after the second of these, a dropout layer is additionally applied with a dropout probability of 20%. Dropout prevents overfitting by randomly disabling neurons during training.