Skip to main content
Have a personal or library account? Click to login
Attention‑Enhanced Convolutional Neural Network for Music Genre Classification Cover

Attention‑Enhanced Convolutional Neural Network for Music Genre Classification

Open Access
|Aug 2026

Full Article

1 Introduction

Music, a universal language, has captivated human minds for centuries. Music constitutes a significant aspect of human life, exerting profound influence on cognitive functions such as concentration and stress management. Moreover, it has the potential to significantly enhance human well‑being across physical, mental, emotional, and spiritual dimensions by mitigating negative emotional states such as feelings of isolation, sadness, and depression (Eerola et al., 2018). With the advent of digital technology, music consumption has transformed dramatically, leading to an exponential growth in music databases. Effective organization and retrieval of this vast music collection has become a critical challenge. Music genre classification (MGC) (Li and Ogihara, 2005; Tzanetakis and Cook, 2002), the task of automatically assigning music pieces to their respective genres, emerges as a fundamental problem in music information retrieval (MIR) (Li and Ogihara, 2006; Müller et al., 2018).

Music genre is a multifaceted concept shaped by musical characteristics as well as cultural and perceptual influences. Attributes such as timber, rhythm, harmony, and instrumentation contribute to genre perception, while genre boundaries are often subjective and may overlap with related concepts such as style or mood (McKay and Fujinaga, 2006; Sturm, 2014). Consequently, MGC should be viewed as the task of learning patterns associated with existing genre annotations rather than identifying universally defined musical categories (Flexer, 2007; Sturm, 2014). Nevertheless, genre labels remain one of the most widely used mechanisms for organizing, retrieving, and recommending music, motivating continued research in automated MGC (Ramírez and Flores, 2020). From a user perspective, accurate genre classification can enhance music‑recommendation systems, personalized playlists, and music‑discovery platforms. In the music industry, it can aid in music cataloging (Pushparajan et al., 2022), copyright management, and targeted marketing. Moreover, the applications of MGC extend beyond the entertainment domain. In the medical field, music therapy has gained significant attention for its potential to improve patient outcomes. By accurately classifying music genres, researchers can develop tailored music interventions for different patient populations (Nunes et al., 2024). For instance, calming music genres might be beneficial for stress reduction, while upbeat music could be used to enhance mood and motivation (Asif et al., 2019). Additionally, MGC can aid in studying the effects of music on brain activity and emotional responses (Markov and Matsui, 2014).

Traditional approaches to MGC primarily focused on handcrafted features and machine learning algorithms (Li and Ogihara, 2005; Tzanetakis and Cook, 2002). However, the limitations of these methods became apparent as the complexity of the problem increased. In recent years, deep learning has emerged as a powerful paradigm for addressing these limitations (Balaji et al., 2019). Convolutional neural networks (CNNs) have been widely adopted for music genre classification (Zhang et al., 2016). To effectively apply CNNs to music, raw audio signals are often converted into mel‑spectrograms (Li et al., 2022). Mel‑spectrograms offer several advantages over raw audio signals. First, they condense the high‑dimensional raw audio data into a lower‑dimensional representation that aligns better with human auditory perception. This dimensionality reduction facilitates efficient feature extraction and model training. Additionally, mel‑spectrograms provide a time‑frequency representation, capturing the evolution of spectral content over time, which is crucial for discerning the rhythmic and harmonic characteristics that differentiate music genres. CNNs are effective in capturing local spatial patterns in mel‑spectrograms, a crucial aspect of MGC (Dhall et al., 2021). However, their inability to grasp global contextual relationships hinders their capacity to capture long‑range dependencies across the spectrogram. To address this limitation, we explored a CNN–long short‑term memory (CNN–LSTM) architecture (Ghosal and Kolekar, 2018), in which the CNN extracts spatial features while the LSTM models temporal dependencies. Despite improved sequence understanding, CNN‑LSTM models struggle to integrate spatial and temporal features seamlessly, leading to increased complexity and potential overfitting.

To overcome these limitations, we propose an attention‑enhanced CNN model (AECNN). By combining the local feature‑extraction capabilities of CNNs with the attention mechanism, the AECNN captures both local features and long‑range contextual relationships within the audio segment more effectively. Our approach offers a more efficient and robust framework for modeling complex spectrogram relationships, leading to enhanced classification performance while maintaining computational efficiency, outperforming traditional CNN and CNN‑LSTM architectures.

To validate the efficiency of our proposed method, we conduct two distinct case studies. The first case study focuses on Western music genre classification using the public domain GTZAN dataset (Tzanetakis and Cook, 2002), which encompasses 10 genres. The second case study delves into Indian music genre classification, for which we developed a dedicated dataset (IMG‑Amrita) comprising 12 genres of Indian music. By evaluating our model on both Western and Indian music genres, we aim to demonstrate its robustness and generalizability. Collectively, these diverse case studies provide compelling evidence of our proposed method’s effectiveness in MGC.

2 Related Work

Music genre classification, a core task in MIR (Li and Ogihara, 2006; Ramí­rez and Flores, 2020), aims to automatically categorize audio signals into their respective genres. Early research primarily relied on hand‑crafted features, such as mel‑frequency cepstral coefficients and chromagrams, combined with traditional machine learning algorithms like support vector machines (SVMs) and hidden Markov models (da Silva et al., 2020; Shao et al., 2004; Xu et al., 2003). Tzanetakis and Cook (Tzanetakis and Cook, 2002) proposed a framework for automatic MGC using timbral, rhythmic, and pitch‑based features along with statistical pattern‑recognition techniques such as Gaussian classifiers, Gaussian mixture models, and k‑nearest neighbour (k‑NN) classifiers. Nanni et al. (2016) proposed a novel method for MGC that combines visual and acoustic features using heterogeneous SVM classifiers, outperforming existing methods without manual parameter tuning. Panagakis et al. (2014) proposed a joint sparse low‑rank representation framework for MGC, outperforming existing methods like sparse representation, nearest subspace, SVM, and nearest neighbor classifiers on multiple benchmark datasets by effectively denoising test samples and identifying underlying subspaces. Folorunso et al. (2022) contributed to the understanding of Nigerian music genres by applying machine learning models such as k‑NN, SVM, extreme gradient boosting, and random forest. However, though the conventional machine learning methods could classify music genres reasonably well, they often struggled with complex and diverse music datasets.

With the advent of deep learning, significant advancements have been made in MGC. CNNs have emerged as the dominant approach, particularly when applied to spectrogram representations of audio data (Dhall et al., 2021). Hongdan et al. (2022) proposed a deep learning–based approach for music genre analysis, significantly improving genre‑identification accuracy and efficiency through advanced feature‑extraction and ‑classification techniques. Bahuleyan (2018) contributed to MGC by comparing deep learning and traditional machine learning approaches; their study used CNNs trained on mel‑spectrograms for a deep learning model while employing hand‑crafted features from both time and frequency domains for traditional classifiers. Liu et al. (2021) proposed a novel CNN architecture for MGC that effectively leverages low‑level audio spectrograms and incorporates long‑range contextual information.

However, CNNs are limited in modeling long‑range dependencies, hindering their ability to capture the overall structure of a music piece. To address this limitation, recurrent neural networks (RNNs) (Ashraf et al., 2023; Schneider et al., 2021), especially LSTM (Fulzele et al., 2018) networks, have been explored. These models excel at capturing temporal dependencies, but they often struggle with computational efficiency and may not fully exploit the spatial information present in spectrograms. Liuwanyue (2024) addressed the challenge of MGC in the era of big data by proposing a deep learning–based approach. Their study compares LSTM and CNN models, incorporating mel‑filters for enhanced feature extraction. By analyzing drift patterns and conducting performance tests, the author sought to improve MGC effectiveness. Recent research has focused on combining the strengths of CNNs and RNNs to create hybrid models (Cheng et al., 2020). Such approaches aim to leverage the local feature‑extraction capabilities of CNNs and the temporal modeling abilities of RNNs. Yang et al. (2020) proposed a novel parallel recurrent CNN (PRCNN) architecture for MGC, effectively combining CNNs and RNNs to capture both spatial and temporal features. The model outperforms traditional methods and demonstrates improved performance over existing deep learning approaches. While these hybrid models have shown promising results, they often involve complex architectures and require careful hyper‑parameter tuning.

Transfer learning (Ananthanarayana et al., 2023; Asswin et al., 2023) offers a compelling alternative by leveraging knowledge acquired from one task to improve performance on a related but different task. In the context of music genre classification, transfer learning can expedite model development, enhance generalization, and potentially improve performance, even with limited available data. Prabhakar and Lee (2023) proposed a comprehensive approach to MGC, exploring five distinct methodologies that include traditional techniques like weighted visibility graph and elastic net and advanced methods such as sequential machine learning, Riemannian alliance, and transfer learning. Hasib et al. (2022) introduced BMNet‑5, a deep learning model for classifying six Bengali music genres using nine audio features. Yu et al. (2020) proposed an attention‑based model for MGC, addressing the limitations of CNN‑based methods that treat all spectrogram frames equally. By incorporating bidirectional RNNs and attention mechanisms, their model effectively captures the varying importance of different spectral regions, outperforming previous approaches.

In recent years, transformer‑based models have gained prominence in various fields, including natural language processing and computer vision (Han et al., 2022; Zaman et al., 2023). The self‑attention mechanism in transformers enables them to capture long‑range dependencies effectively. This has led to their application in music‑related tasks, including genre classification (Zhao et al., 2022). Transformers have demonstrated superior performance compared to CNNs and RNNs, especially when dealing with complex and diverse music datasets. Hassani et al. (2021) challenge the perception of transformers as data‑intensive models by introducing compact transformer architectures. Their work demonstrates effective performance on smaller datasets with fewer parameters. While promising, their study acknowledges potential limitations in handling extremely diverse or complex datasets compared to larger transformer models.

In the broader MIR literature, genre has long been recognized as a flexible and context‑dependent concept rather than a strictly defined category. Prior work has shown that genre‑classification performance is influenced by factors such as feature source selection, temporal segmentation, and representational granularity. Studies on anchor‑space representations emphasize the relationship between classification and similarity measurement (Berenzweig et al., 2003), while segmentation‑based analyses highlight the impact of temporal structure on genre decisions (West and Cox, 2005). More recent investigations further demonstrate that reducing time–frequency resolution can substantially affect CNN‑based music tagging performance (Ferraro et al., 2020), and multi‑objective evaluations reveal the influence of feature source diversity and modality integration on classification outcomes (Vatolkin and McKay, 2022). Building on these insights, the present study treats genre classification as one component within a wider MIR ecosystem rather than as an isolated task.

Motivated by these considerations, we propose an AECNN for MGC. The model integrates convolutional feature extraction with an attention mechanism to capture both localized time–frequency patterns and long‑range contextual relationships within the audio. By balancing representational expressiveness with computational efficiency, the proposed architecture aims to address limitations observed in purely convolutional or recurrent frameworks while remaining suitable for moderate‑scale MIR datasets.

3 Database Description

In this work, we use the widely recognized GTZAN dataset, a benchmark for Western music genre classification. We also use IMG‑Amrita, a comprehensive Indian music genre database, to facilitate the development of an MGC system tailored to Indian music. This dataset serves as the cornerstone of our research, providing a rich and diverse collection of Indian music samples. By comparing our system’s performance on both Western and Indian music, we aim to establish its robustness and applicability across different cultural contexts.

3.1 Western music genre dataset (GTZAN)

The GTZAN dataset, a benchmark in MGC, was curated by Tzanetakis and Cook (2002). The dataset contains 1000 audio tracks from 10 genres of Western music—namely, Blues, Classical, Country, Disco, Hiphop, Jazz, Metal, Pop, Reggae, and Rock. Each genre has 100 audio files with a duration of 30 s each. The audio files are in ‘.wav’ format with a sampling rate of 22.05 kHz and a bit rate of 352 kbps. Each 30‑s recording was further segmented into fixed‑duration clips (15, 10, 6, and 3 s).

3.2 Indian music genre dataset (IMG‑Amrita)

Indian music is characterized by a vast and varied array of genres, each with its own distinct history, traditions, and characteristics. IMG‑Amrita was created by us exclusively for this research work. It was curated to represent 12 prominent Indian music genres: Baul, Bihu, Carnatic, Cinematic, Ghazal, Hindustani, Kathakali, Punjabi, Rabindra Sangeet, Rajasthani Folk, Sopana Sangeet, and Sufi. Recordings were obtained from publicly accessible sources and public performance archives to capture realistic acoustic conditions. Selection criteria required clear genre identity, adequate recording quality, and representative vocal–instrumental characteristics.

For methodological consistency and comparability with GTZAN, all IMG‑Amrita recordings were standardized to 30‑s excerpts. This uniform duration ensures consistent feature extraction and avoids bias due to variable‑length inputs. Each genre includes 150 clips (30 s each), totaling 75 min per genre. Each 30‑s recording was further segmented into fixed‑duration clips (15, 10, 6, and 3 s). Genre labels were manually assigned and verified by an experienced musician with expertise in Indian classical and folk traditions. Ambiguous or cross‑genre recordings were excluded to ensure annotation reliability. The audio files are in ‘.wav’ format with a sampling rate of 48.00 kHz and a bit rate of 768 kbps.

The dataset statistics are summarized in Tables 1 and 2 for GTZAN and IMG‑Amrita, respectively. For both GTZAN and IMG‑Amrita, an 80–20 stratified split (training–test) was applied at the track level prior to segmentation to prevent data leakage.

Table 1

GTZAN dataset statistics.

Segment DurationSegments per 30‑s TrackTotal SegmentsTraining (80%)Testing (20%)
30 s11000800200
15 s220001600400
10 s330002400600
6 s5500040001000
3 s101000080002000
Table 2

IMG‑Amrita dataset statistics.

Segment DurationSegments per 30‑s TrackTotal SegmentsTraining (80%)Testing (20%)
30 s118001440360
15 s236002880720
10 s3540043201080
6 s5900072001800
3 s1018000144003600

3.3 Dataset limitations

The GTZAN dataset, while widely adopted as a benchmark for Western music genre classification, is known to contain certain limitations, including duplicate excerpts, occasional mislabelling, and imbalances in genre representation (Jerzak, 2025; Sturm, 2013). These issues can lead to inflated performance estimates, particularly under random train–test splits. In this study, GTZAN is therefore used primarily to enable comparison with prior work, and the reported results should be interpreted in this context rather than as definitive indicators of real‑world generalization.

The IMG‑Amrita dataset, developed for this research, also has inherent constraints. It was compiled from publicly available recordings and may reflect variations in recording quality and production style. Although genres are balanced in sample count, the dataset does not yet capture the full regional and stylistic diversity of Indian music traditions. Future work will focus on expanding the dataset, incorporating additional genres and performers, and validating annotations through expert review and cross‑dataset evaluation.

4 Methodology

This section describes the methodology adopted for MGC. The workflow consists of three main stages: data augmentation, mel‑spectrogram extraction, and classification using deep learning models. Audio signals were first augmented to improve robustness; transformed into mel‑spectrogram representations; and then classified using CNN‑based architectures, including the proposed AECNN model.

4.1 Data augmentation

To improve model generalization and robustness, waveform‑level audio augmentation was performed prior to mel‑spectrogram extraction. The applied transformations introduce realistic acoustic variability while preserving genre‑discriminative characteristics.

4.1.1 Time stretching

Time stretching modifies the temporal scale of the signal without altering pitch. For an audio signal x(t), the time‑stretched signal xα(t) is defined as

1
xα(t)=x(αt)

where α{0.9,1.1} represents the stretch factor. This operation preserves harmonic content while simulating tempo variations, encouraging tempo‑invariant feature learning.

4.1.2 Pitch shifting

Pitch shifting modifies the frequency content while preserving duration. In the frequency domain, this corresponds to shifting spectral components:

2
XΔf=X(fΔf)

where Δf corresponds to ±1 semitone. Since one semitone equals a frequency scaling factor of 21/12, the modified signal can be approximated as

3
xβ(t)=x(2±1/12t)

This transformation introduces variation in harmonic positioning while maintaining rhythmic structure.

4.1.3 Noise addition

To simulate recording artifacts, Gaussian noise n(t)N(0,σ2) was added:

4
xn(t)=x(t)+n(t)

The noise variance σ2 was controlled to achieve a signal‑to‑noise ratio of 20 dB:

5
SNRdb=10log10(E[x(t)2]E[n(t)2])

4.1.4 Dynamic range compression

Dynamic range compression was applied using amplitude thresholding:

6
xc(t)={Tsgn(x(t))|x(t)|>Tx(t)otherwise

where T is the compression threshold. This emulates mastering effects while preserving temporal structure.

4.2 Mel‑Spectrogram extraction

Mel‑spectrograms were used as input features. This representation maps frequency bins onto the perceptually motivated mel scale, providing a compact time–frequency description suitable for audio classification (Cheng and Kuo, 2022).

The mel‑spectrogram Smel(t,f) is defined as

7
Smel(t,f)=n=1N|X(t,n)2|W(n,f),

where X(t,n) is the short‑time Fourier transform (STFT) (Cheng and Kuo, 2022) and W(n,f) is the mel filter bank. The mel mapping is

8
Mel(f)=2595log10(1+f700).

STFT is first applied to obtain a spectrogram, followed by mel filtering to emphasize perceptually relevant structure. An example is shown in Figure 1.

Figure 1

Mel‑spectrogram of a 15‑s music signal.

4.3 Classification algorithms

Classifiers are essential tools for MGC, enabling the automatic categorization of audio tracks into predefined genres. Various deep learning algorithms such as CNNs have been employed for this task. The choice of classifier depends on factors like dataset size, computational resources, and desired accuracy. Experimentation with different classifiers is often necessary to identify the most suitable one for a specific music genre–classification task. The classifiers used in this work are detailed below.

4.3.1 CNNs

CNNs were used as baseline classifiers for spectrogram‑based genre classification (Oramas et al., 2018; Zhang et al., 2016). A convolutional layer applies learnable filters WfRk×k×ci to an input feature map XlRM×N×ci to produce output feature maps:

9
Fmn(x,y)=i=1cip=k12k12q=k12k12Wfn,i(p,q)Xx+p,y+q,il+bmn.

Convolutional layers capture localized time–frequency patterns in spectrogram inputs, while pooling reduces spatial dimensionality. Stacked layers enable hierarchical feature learning for genre classification. The baseline CNN architecture is shown in Figure 2.

Figure 2

Architecture of the convolutional neural network.

4.3.2 CNN‑LSTM network

A CNN–LSTM architecture was used as a hybrid baseline for genre classification (Ghosal and Kolekar, 2018). The model combines convolutional layers for local time–frequency feature extraction with LSTM layers for temporal dependency modeling. Convolution is expressed as

10
output[i,j]=f(m,ninput[i+m,j+n]filter[m,n]),

where m and n are the horizontal and vertical kernel indices, respectively, and f is the nonlinear activation function. Temporal dynamics are captured by LSTM gating operations:

11
ft=σ(Wf[ht1,xt])
12
it=σ(Wi[ht1,xt])
13
ot=σ(Wo[ht1,xt])
14
ct=ftct1+ittanh(Wc[ht1,xt]),

with standard notation. The resulting representation is passed to fully connected and softmax layers for classification. The architecture is shown in Figure 3.

Figure 3

Convolutional neural network—long‑term short memory network architecture.

5 Proposed AECNN

This work introduces an architecture for MGC that leverages the complementary strengths of CNNs and a self‑attention mechanism. As depicted in Figure 4, the proposed AECNN consists of two principal components: a feature‑extractor module F, responsible for learning high‑level representations from mel‑spectrogram inputs, and a classifier module CL, which maps the learned representations to genre labels.

Figure 4

The architecture and training steps of the proposed model.

Raw audio signals are first converted into mel‑spectrograms, which provide a compact time‑frequency representation of the signal. Let the input spectrogram be denoted as

15
XRH×W×C,

where H and W represent the temporal and frequency dimensions, respectively, and C denotes the number of channels.

The feature‑extractor component F, illustrated in Figure 5, adopts a hybrid strategy to capture both localized and global contextual information. The CNN module processes the input XRH×W×C through a series of convolutional layers. At layer l, the input tensor is denoted as

Figure 5

Feature‑extractor network.

16
X(l)RM×N×ci,

where M and N represent spatial dimensions and ci denotes the number of input channels. Each convolutional layer contains co learnable filters, where co denotes the number of output channels. The n‑th filter is represented as

17
Wf(n)Rk×k×ci,n=1,,co,

where k is the kernel size. The convolution operation producing the n‑th output feature map is defined as

18
F(l,n)(x,y)=i=1cip=k/2k/2q=k/2k/2Wf(n,i)(p,q)X(l)(x+p,y+q,i)+b(n),

where b(n) denotes the bias term associated with the n‑th filter. The resulting feature tensor becomes

19
F(l)RM×N×co,

where M and N depend on the stride and padding. Batch normalization, nonlinear activation, and max‑pooling operations are applied to progressively extract localized spectral–temporal patterns and reduce spatial dimensionality.

After the final convolutional stage, high‑level feature maps are obtained:

20
FCNNRH×W×C.

While CNNs effectively learn local patterns, their receptive field remains constrained. To enable modeling of non‑local interactions across distant time–frequency regions within each input segment, a self‑attention mechanism is incorporated.

The convolutional feature maps are reshaped into a sequence of patch embeddings:

21
P=Reshape(FCNN)RN×D,

where N=HW denotes the number of patches and D=C represents the embedding dimension. To retain positional information, a learnable positional encoding matrix ERN×D is added:

22
P=P+E.

The sequence P is linearly projected into query, key, and value representations:

23
Q=PWQ,K=PWK,V=PWV,

where WQ,WKRD×dk and WVRD×dv are trainable projection matrices. Consequently,

Q,KRN×dk,VRN×dv.

Each row vector qi,ki,vi corresponds to the query, key, and value representations of the i‑th patch. The similarity between patches is computed using scaled dot‑product attention:

24
Attention(Q,K,V)=Softmax(QKTdk)V.

The matrix QKTRN×N captures pairwise interactions between all patches. The scaling factor dk stabilizes gradient updates, and the softmax operation normalizes each row into a probability distribution. The output representation is obtained as a weighted aggregation:

25
hi=j=1Nαijvj,

where αij denotes the normalized attention weight between patches i and j. This formulation enables each patch to incorporate contextual information from all other patches, thereby modeling global time–frequency interactions within the analyzed segment. In this work, the term ‘global dependency’ refers to such non‑local patch‑wise interactions rather than to modeling complete song‑level structure.

Two parallel attention heads are employed to enhance representational diversity:

26
H1=Attention(Q1,K1,V1),H2=Attention(Q2,K2,V2).

The outputs are aggregated as

27
Hagg=H1+H2.

The aggregated representation HaggRN×D is condensed into a compact feature vector through attention‑based sequence pooling. A learnable projection vector wpRD computes importance weights:

28
α=Softmax(Haggwp),

and the final representation is obtained as

29
z=i=1Nαihi.

Unlike global average pooling, this mechanism adaptively emphasizes discriminative time–frequency regions.

The condensed representation zRD is passed to a fully connected classifier:

30
y^=Wz+b,

where WRK×D and bRK, with K denoting the number of genre classes. The predicted probabilities are obtained using the softmax function:

31
pk=exp(y^k)j=1Kexp(y^j)

The network is trained by minimizing the categorical cross‑entropy loss (LC):

32
LC=k=1Kyklog(pk),

where yk denotes the one‑hot encoded ground‑truth label. By combining convolutional local feature extraction with global patch‑wise contextual modeling, the proposed AECNN effectively captures discriminative time–frequency characteristics for music genre classification. The overall workflow of the proposed method is summarized in Algorithm 1.

Algorithm 1:

Proposed AECNN Framework

Require: Audio dataset D=(Ai,yi)i=1N, segment duration Ts, sampling frequency Fs

Ensure: Trained classifier M

1: Initialize training set T

2: for each audio recording AiD do

3:  Segment Ai into fixed‑duration clips

4:  Apply data augmentation:

  Time stretching

  Pitch shifting

  Noise addition

  Dynamic range compression

5:  for each augmented segment aij do

6:    Compute STFT(aij)

7:    Generate log‑mel spectrogram Sij

8:    Resize Sij to input dimension H×W×C

9:    TT{(Sij,yi)}

10:  end for

11: end for

12: Split T into training set Ttrain and testing set Ttest

13: Initialize model parameters θ

14: while stopping criterion not satisfied do

15:  Sample mini‑batch BTtrain

16:  for each spectrogram SkB do

17:   F1CNNLayer1(Sk)

18:   F2CNNLayer2(F1)

19:   PPatchEmbedding(F2)

20:   EP+PositionalEncoding(P)

21:   H1AttentionHead1(E)

22:   H2AttentionHead2(E)

23:   HConcatenate(H1,H2)

24:   HLayerNormalization(H)

25:   HFeedForwardNetwork(H)

26:   HResidualConnection(H)

27:   zFullyConnected(H)

28:   pSoftmax(z)

29:  end for

30:  Compute categorical cross‑entropy loss

31:  Update parameters (θ) using AdamW optimizer

32: end while

33: Evaluate classifier using:

   Classification accuracy

   Top‑five accuracy

   Confusion matrix

   Area under the receiver operating characteristic curve

34: return trained model M

6 Experiments and Results

In this study, we explored different deep learning approaches for Western and Indian music genre classification using the GTZAN and IMG‑Amrita datasets. Finally, we propose a method called AECNN that integrates convolutional feature extraction with attention‑based contextual modeling to improve genre‑classification performance. To ensure robustness, each experiment was repeated five times, and the results reported are the mean values across all runs. This section outlines the outcomes of our experiments and the results of the performance evaluations.

6.1 Deep learning–based MGC system

Conventional machine learning methods often struggle with heterogeneous music datasets due to limited representational capacity. Deep learning, particularly CNNs, has significantly advanced MGC by enabling hierarchical feature extraction from mel‑spectrogram representations. In this study, data‑augmentation techniques (Pushparajan et al., 2024), including time stretching, pitch shifting, noise addition, and dynamic range compression, were applied to the training data to improve model robustness and generalization. The augmented audio samples were subsequently converted into mel‑spectrogram representations, which were used as input to the CNN architecture for learning discriminative spectral patterns. The quantitative results for the Western (GTZAN) and Indian (IMG‑Amrita) datasets are presented in Tables 3 and 4, respectively. Each configuration was evaluated over five independent runs, and results are reported as mean accuracy ± standard deviation with corresponding 95% confidence intervals. Statistical significance between models was assessed using paired t tests. Before performing statistical comparisons, we verified the normality of the repeated experimental results using the Shapiro–Wilk test. The test indicated that the data were approximately normally distributed (p > 0.05), supporting the use of paired t tests for significance testing.

Table 3

Statistical comparison of CNN and CNN‑LSTM on the GTZAN dataset (mean ± SD, 95% CI, paired t test).

DurationCNN (Mean Acc. ± SD)95% CICNN‑LSTM (Mean Acc. ± SD)95% CIp‑value
30 s83.05 ± 0.45[82.49, 83.61]84.55 ± 0.48[83.96, 85.14]0.004
15 s83.92 ± 0.44[83.38, 84.46]85.22 ± 0.47[84.64, 85.80]0.006
10 s85.25 ± 0.42[84.73, 85.77]87.32 ± 0.50[86.69, 87.95]<0.001
6 s86.13 ± 0.41[85.62, 86.64]88.45 ± 0.52[87.80, 89.10]<0.001
3 s87.05 ± 0.40[86.56, 87.54]89.63 ± 0.55[88.94, 90.32]<0.001
Table 4

Statistical comparison of CNN and CNN‑LSTM on the IMG‑Amrita dataset (mean ± SD, 95% CI, paired t test).

DurationCNN (Mean Acc. ± SD)95% CICNN‑LSTM (Mean Acc. ± SD)95% CIp‑value
30 s90.80 ± 0.43[90.27, 91.33]91.52 ± 0.46[90.95, 92.09]0.041
15 s91.45 ± 0.41[90.94, 91.96]91.89 ± 0.44[91.35, 92.43]0.083
10 s92.05 ± 0.39[91.56, 92.54]93.11 ± 0.47[92.53, 93.69]0.009
6 s93.23 ± 0.38[92.76, 93.70]95.05 ± 0.49[94.44, 95.66]<0.001
3 s95.55 ± 0.36[95.10, 96.00]96.67 ± 0.42[96.15, 97.19]0.003

Although CNNs effectively model localized spectral features, their capacity to capture extended temporal dependencies is limited. To address this, a hybrid CNN‑LSTM architecture was employed. As shown in Tables 3 and 4, CNN‑LSTM consistently outperformed the CNN baseline across most segment durations, with statistically significant improvements (p < 0.05 in the majority of cases), confirming the advantage of incorporating temporal modeling.

The highest accuracy was obtained for 3‑s segments on both datasets. This suggests that sufficient genre‑discriminative information is present within relatively short temporal windows. Longer segments may introduce structural transitions and increased intra‑class variability, which can dilute discriminative information and increase modeling complexity. Therefore, the improved performance observed for shorter durations likely reflects an optimal trade‑off between contextual sufficiency and statistical stability rather than a limitation of long‑range contextual modeling. The hyperparameters used for training the CNN and CNN‑LSTM models are summarized in Table 5. To ensure a fair comparison, both models were trained using identical optimization and training settings.

Table 5

Training hyperparameters of the CNN and CNN‑LSTM models.

HyperparameterValue
OptimizerAdam
Learning rate0.001
Loss functionCategorical cross‑entropy
Batch size128
Number of epochs100
Early stopping patience10
Learning rate reduction patience5
Learning rate reduction factor0.5
Minimum learning rate1e‑5

Overall, the results demonstrate that integrating LSTM layers enhances classification robustness, while appropriate segment length selection further strengthens discriminative performance across culturally distinct music datasets.

6.2 AECNN

This research introduces an AECNN model that significantly improves the classification of both Western and Indian music genres. By effectively integrating CNNs with an attention mechanism, the model leverages the strengths of both approaches. CNNs excel at extracting local features from the audio data, while the attention mechanism effectively captures long‑range temporal dependencies within the input audio segment. This synergistic combination enhances the model’s ability to understand and classify complex musical patterns. Furthermore, the incorporation of convolutional layers reduces computational complexity and improves feature learning efficiency compared to traditional methods, making the proposed model more computationally efficient and effective for music genre classification.

For the proposed AECNN method, the augmented audio samples were converted into mel‑spectrogram representations and subsequently used as input to the network. Performance was evaluated across segment durations of 30, 15, 10, 6, and 3 s. Tables 6 and 7 present the statistical performance evaluation of AECNN on the GTZAN and IMG‑Amrita datasets, respectively, reported as mean accuracy ± standard deviation over five independent runs, along with 95% confidence intervals computed using the t‑distribution. Paired t tests comparing AECNN with CNN and CNN‑LSTM indicate statistically significant improvements across most segment durations, particularly for shorter segments. The narrow confidence intervals confirm stable convergence and consistent generalization. The highest accuracy was obtained for 3‑s segments. From a bias‑variance perspective, shorter segmentation increases the effective number of training samples, reducing estimator variance and improving generalization stability. In contrast, longer segments yield fewer training instances and may introduce structural transitions and intra‑class variability that dilute discriminative information. Since sufficient genre‑discriminative information is present within relatively short temporal windows, shorter segments provide an optimal balance between contextual sufficiency and statistical efficiency. To further analyze the model’s behavior, confusion matrices and areas under the receiver operating characteristic curve were employed. The results depicted in Figures 6, 7, 8, and 9 confirm that AECNN is a promising method for genre classification, particularly in scenarios with diverse genre distributions and limited data.

Table 6

Statistical erformance valuation of the AECNN‑based MGC system (GTZAN) (mean ± SD, 95% CI, paired t test).

DurationAECNN (Mean Acc. SD)95% CIp‑value vs. CNNp‑value vs. CNN‑LSTM
30 s90.68 ± 0.43[90.14, 91.22]0.0020.006
15 s91.12 ± 0.45[90.56, 91.68]0.0010.004
10 s92.05 ± 0.46[91.48, 92.62]<0.0010.002
6 s93.82 ± 0.48[93.22, 94.42]<0.001<0.001
3 s96.02 ± 0.51[95.39, 96.65]<0.001<0.001
Table 7

Statistical performance evaluation of the AECNN‑based MGC system (IMG‑Amrita) (mean ± SD, 95% CI, paired t test).

DurationAECNN (Mean Acc. SD)95% CIp‑value vs. CNNp‑value vs. CNN‑LSTM
30 s93.62 ± 0.40[93.12, 94.12]0.0030.021
15 s94.68 ± 0.42[94.15, 95.21]0.0020.014
10 s95.94 ± 0.44[95.39, 96.49]0.0010.006
6 s98.21 ± 0.47[97.62, 98.80]<0.0010.002
3 s98.94 ± 0.46[98.36, 99.52]<0.001<0.001
Figure 6

Confusion matrix of the attention‑enhanced convolutional neural network–based music genre classification system (3 s) (Western genre).

Figure 7

Area under the receiver operating characteristic curve analysis of the attention‑enhanced convolutional neural network–based music genre classification system (3 s) (Western genre).

Figure 8

Confusion matrix of the attention‑enhanced convolutional neural network–based music genre classification system (3 s) (Indian genre).

Figure 9

Area under the receiver operating characteristic curve analysis of the attention‑enhanced convolutional neural network–based music genre classification system (3 s) (Indian genre).

The performance metrics of CNN, CNN‑LSTM, and the proposed model are compared in Table 8. AECNN consistently achieves superior performance across all metrics, confirming improved class‑level discrimination and balanced predictive behavior across both datasets.

Table 8

Performance comparison of the CNN and CNN‑LSTM with the proposed method.

GenreMethodAccuracy (%)Precision (%)Recall (%)F1‑Score (%)
WesternCNN87.0587.6587.2086.40
CNN‑LSTM89.6390.0389.5588.74
Proposed method96.0296.4895.6396.05
IndianCNN95.5595.9094.8794.34
CNN‑LSTM96.6797.1296.0595.40
Proposed method98.9499.1298.6398.87

The key architectural and training hyperparameters of the proposed AECNN model are summarized in Table 9. The model was optimized using the AdamW optimizer with a learning rate of 0.001 and weight decay of 0.0001. Training was conducted for 100 epochs with a batch size of 128. To enhance generalization and mitigate overfitting, regularization techniques including dropout (rate = 0.1), stochastic depth (rate = 0.01), weight decay, and label smoothing (factor = 0.1) were employed. The dataset was divided into 80% training data and 20% testing data. From the training data, 10% was used for validation. The validation set was used for model selection based on validation accuracy, while the test set was reserved for final performance evaluation. All experiments were performed on a high‑performance computing system equipped with an Intel Xeon processor, 256 GB RAM, and an NVIDIA Tesla V100 GPU.

Table 9

Training hyperparameters of the proposed AECNN model.

HyperparameterValue
OptimizerAdamW
Learning rate1×103
Weight decay1×104
Batch size128
Number of epochs100
Loss functionCategorical cross‑entropy
Label smoothing0.1
Dropout rate0.1
Stochastic depth rate0.01

6.3 Ablation study

To rigorously assess the effectiveness of our proposed AECNN model for MGC, we conducted an ablation study. This analysis systematically removed key components of the AECNN to evaluate their individual contributions. The results, presented in Tables 10 and 11, demonstrate the crucial role of each component in achieving the model’s high accuracies of 96.02% and 98.94% for the GTZAN and IMG‑Amrita datasets, respectively. Notably, removing the attention module resulted in significant accuracy drops to 89.11% and 96.00% for GTZAN and IMG‑Amrita, respectively, emphasizing the importance of the attention mechanism in capturing global dependencies and spatial relationships within the audio data. Furthermore, decreasing the depth of the CNN or removing batch normalization led to further performance degradation. These findings underscore the necessity of all components, including the attention module, CNN architecture, and batch normalization, in achieving state‑of‑the‑art music genre classification performance with the AECNN.

Table 10

Results of the ablation study (Western genre).

ConfigurationDescriptionAccuracy (%) Mean ± SD [95% CI]Precision (%) Mean ± SD [95% CI]Recall (%) Mean ± SD [95% CI]F1 Score Mean ± SD [95% CI]
Without batch normalizationRemoved batch normalization from convolutional layers93.53 ± 0.38
[93.20, 93.86]
94.08 ± 0.35
[93.77, 94.39]
92.87 ± 0.41
[92.51, 93.23]
93.47 ± 0.37
[93.15, 93.79]
Reduced CNN depthReduced the depth of the CNN backbone (from 3 to 2)92.79 ± 0.42
[92.42, 93.16]
93.41 ± 0.39
[93.07, 93.75]
92.06 ± 0.44
[91.67, 92.45]
92.73 ± 0.40
[92.38, 93.08]
Reduced attention headsReduced the number of attention heads (from 2 to 1)92.03 ± 0.46
[91.63, 92.43]
92.68 ± 0.43
[92.30, 93.06]
91.42 ± 0.48
[91.00, 91.84]
92.04 ± 0.45
[91.65, 92.43]
Increased attention headsIncreased the number of attention heads (from 2 to 3)94.98 ± 0.34
[94.68, 95.28]
95.37 ± 0.31
[95.10, 95.64]
94.52 ± 0.36
[94.20, 94.84]
94.94 ± 0.33
[94.65, 95.23]
Without attention moduleRemoved the attention module; only CNN remains89.11 ± 0.51
[88.66, 89.56]
90.02 ± 0.48
[89.60, 90.44]
88.27 ± 0.55
[87.79, 88.75]
89.13 ± 0.50
[88.69, 89.57]
Proposed AECNNComplete architecture (CNN + dual attention modules)96.02 ± 0.29
[95.76, 96.28]
96.48 ± 0.27
[96.24, 96.72]
95.63 ± 0.31
[95.36, 95.90]
96.05 ± 0.28
[95.80, 96.30]
Table 11

Results of the ablation study (Indian genre).

ConfigurationDescriptionAccuracy (%) Mean ± SD [95% CI]Precision (%) Mean ± SD [95% CI]Recall (%) Mean ± SD [95% CI]F1 Score Mean ± SD [95% CI]
Without batch normalizationRemoved batch normalization from convolutional layers97.53 ± 0.27
[97.29, 97.77]
97.88 ± 0.25
[97.66, 98.10]
97.21 ± 0.30
[96.95, 97.47]
97.54 ± 0.28
[97.29, 97.79]
Reduced CNN depthReduced the depth of the CNN backbone (from 3 to 2)97.01 ± 0.31
[96.74, 97.28]
97.36 ± 0.29
[97.11, 97.61]
96.68 ± 0.33
[96.39, 96.97]
97.02 ± 0.30
[96.76, 97.28]
Reduced attention headsReduced the number of attention heads (from 2 to 1)96.28 ± 0.36
[95.96, 96.60]
96.71 ± 0.34
[96.41, 97.01]
95.83 ± 0.39
[95.49, 96.17]
96.27 ± 0.35
[95.96, 96.58]
Increased attention headsIncreased the number of attention heads (from 2 to 3)97.88 ± 0.24
[97.67, 98.09]
98.21 ± 0.22
[98.02, 98.40]
97.46 ± 0.27
[97.22, 97.70]
97.83 ± 0.25
[97.61, 98.05]
Without attention moduleRemoved the attention module; only CNN remains96.00 ± 0.40
[95.65, 96.35]
96.38 ± 0.37
[96.06, 96.70]
95.62 ± 0.42
[95.25, 95.99]
95.99 ± 0.39
[95.65, 96.33]
Proposed AECNNComplete architecture (CNN + dual attention modules)98.94 ± 0.18
[98.78, 99.10]
99.12 ± 0.16
[98.98, 99.26]
98.63 ± 0.21
[98.45, 98.81]
98.87 ± 0.19
[98.70, 99.04]

6.4 Comparison with the state‑of‑the‑art methods

To assess the effectiveness of our proposed model on the GTZAN dataset, we conducted a comparative analysis against state‑of‑the‑art methods, including hybrid CNN–RNN (Ashraf et al., 2023), CNN–transformer encoder (Chen et al., 2024), and compact convolutional transformer (Pourmoazemi and Maleki, 2024). We evaluated performance using standard metrics: accuracy, precision, recall, and F1‑score. The results summarized in Table 12 show that the proposed AECNN achieves competitive performance compared with existing state‑of‑the‑art approaches. The consistent improvements observed across the evaluated datasets suggest that the combination of CNN‑based feature extraction and attention mechanisms is effective for MGC. These findings support the potential of the proposed architecture under the experimental conditions considered in this study. Figure 10 shows a radar chart of the comparison.

Table 12

Comparison of the Proposed AECNN Model with the State‑of‑the‑Art Models for the GTZAN Dataset.

ApproachAccuracy (%)Precision (%)Recall (%)F1‑Score (%)
Hybrid CNN‑RNN (Ashraf et al., 2023)89.3085.0091.0088.00
CNN–transformer encoder (Chen et al., 2024)87.4187.9387.5887.28
Compact convolutional transformer (Pourmoazemi and Maleki, 2024)94.0092.0093.0092.00
Proposed work (AECNN)96.0296.4895.6396.05
Figure 10

Radar chart comparison of the proposed attention‑enhanced convolutional neural network model with the state‑of‑the‑art models for GTZAN dataset.

7 Conclusion

This work presented an AECNN for MGC and systematically investigated the influence of audio duration on classification performance using 30‑, 15‑, 10‑, 6‑, and 3‑s segments. Mel‑spectrogram representations were employed to effectively encode the time–frequency characteristics of music signals. The baseline CNN achieved accuracies of 87.05% and 95.55% for Western and Indian datasets, respectively, using 3‑s inputs. Incorporating temporal modeling through a CNN–LSTM architecture improved performance to 89.63% and 96.67%, respectively, confirming the benefit of capturing sequential dependencies. The proposed AECNN further enhanced performance, achieving 96.02% accuracy for Western MGC and 98.94% accuracy for Indian MGC. Importantly, classification accuracy remained stable across multiple temporal resolutions, indicating that genre‑discriminative information is predominantly embedded in short‑ to mid‑term acoustic patterns such as timbre, instrumentation, and rhythmic texture. These findings demonstrate that short‑duration segments are sufficient for effective genre classification while also increasing the number of training samples and improving generalization robustness. Although the attention mechanism enhances modeling of temporal relationships within each segment, the model primarily captures intra‑segment dependencies rather than full song‑level structure. Overall, the proposed AECNN consistently outperformed baseline deep learning approaches, achieving improvements of 8.97% and 3.39% for Western and Indian MGC, respectively. The results confirm the effectiveness of attention‑enhanced architectures for robust, efficient, and scalable music genre classification in diverse musical contexts.

While the proposed AECNN demonstrates strong performance across Western and Indian music genres, several limitations remain. First, the study was conducted using uniformly encoded WAV audio recordings; therefore, the robustness of the proposed framework to diverse audio formats and lossy compression schemes remains to be explored in future work. Second, genre itself is an inherently subjective and culturally influenced concept, often overlapping with related notions such as mood, emotion, instrumentation, and performance style. As a result, genre boundaries may be ambiguous, particularly in contemporary and hybrid musical forms. The present work therefore treats genre as a pragmatic benchmark label within MIR evaluation frameworks rather than as a definitive musicological construct.

In addition, although experiments were carefully controlled, the datasets remain moderate in scale, and broader cross‑cultural validation would further strengthen generalization claims. Future work will explore richer contextual modelling by integrating complementary descriptors such as mood or style, investigating segmentation‑aware approaches to better capture intra‑track variability and extending the framework to multi‑modal and multi‑objective learning settings. Evaluating robustness under reduced time–frequency resolutions will further clarify trade‑offs between representation fidelity and computational efficiency. These directions position genre classification within a broader MIR ecosystem that reflects both perceptual and structural dimensions of music.

Data Accessibility

The GTZAN dataset used in this study is publicly available through standard online repositories. The IMG‑AMRITA dataset used in this study was developed by the authors and is publicly available at https://github.com/sreekumarkt/IMG-AMRITA.

Competing Interests

The authors have no competing interests to declare.

DOI: https://doi.org/10.5334/tismir.268 | Journal eISSN: 2514-3298
Language: English
Page range: 423 - 439
Submitted on: Apr 10, 2025
Accepted on: Jun 18, 2026
Published on: Aug 4, 2026
Published by: Ubiquity Press
In partnership with: Paradigm Publishing Services

© 2026 M Pushparajan, KT Sreekumar, KI Ramachandran, C Santhosh Kumar, published by Ubiquity Press
This work is licensed under the Creative Commons Attribution 4.0 License.