Music genre classification method, device and readable medium based on three-branch architecture

Through the three-branch architecture music genre classification method, combined with the ConvNeXt-Tiny convolution branch, Performer branch and NLP text processing branch, the problem of high computational complexity of real-time inference on mobile terminals is solved, and lightweight design and high classification accuracy are achieved, which is suitable for mobile applications.

CN120448582BActive Publication Date: 2025-09-16XIAMEN CITY UNIV XIAMEN RADIO & TV UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202510953554.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2025-07-11
Publication Date
2025-09-16
Estimated Expiration
2045-07-11

AI Technical Summary

Technical Problem

Existing music genre classification models have high computational complexity and cost in real-time inference on mobile devices, and fail to effectively utilize lyrics text information, resulting in insufficient classification accuracy.

Method used

A music genre classification method with a three-branch architecture is adopted, including the ConvNeXt-Tiny convolution branch, the Performer branch, and the NLP text processing branch. The audio and lyrics features are extracted respectively, and the features are fused through the gated fusion layer to construct a lightweight music genre classification model.

Benefits of technology

It significantly reduces the computing cost and latency of mobile devices, improves classification accuracy, is suitable for mobile application scenarios, and can effectively integrate audio and lyrics features to enhance user experience.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120448582B_ABST
    Figure CN120448582B_ABST
Patent Text Reader

Abstract

The present invention discloses a music genre classification method, device and readable medium based on a three-branch architecture, which relates to the field of music classification, including: constructing and training a music genre classification model based on the three-branch architecture to obtain a trained music genre classification model; obtaining audio data and corresponding lyrics text of the music to be classified and preprocessing them to obtain a logarithmic Mel-spectrogram and a preprocessed text sequence and inputting them into the trained music genre classification model, the logarithmic Mel-spectrogram corresponding to the audio data is input into the ConvNeXt‑Tiny convolution branch and the Performer branch respectively to obtain local features and global features; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into a gated fusion layer to obtain fused features and input into a classification layer to obtain a predicted audio genre category. The present invention solves the problems such as the high complexity of current feature extraction calculations leading to difficulties in real-time reasoning on mobile terminals.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of music classification, and in particular to a music genre classification method, device and readable medium based on a three-branch architecture. Background Art

[0002] With the rapid adoption of internet technology and mobile devices, online music platforms have gradually become the primary channel for users to access music in their daily lives. As users' music needs become increasingly diverse and personalized, effectively and accurately classifying massive amounts of music data has become a crucial approach to improving user experience. Music genre classification is a key subtask of music information retrieval. By identifying the characteristics, style, and creative context of music, accurately categorizing musical works into specific genres helps users more quickly discover and select music of their interest.

[0003] In recent years, deep learning techniques have been widely used in music classification tasks. Current mainstream approaches include convolutional neural networks (CNNs), recurrent neural networks (RNNs), and Transformer models. These models achieve remarkable classification results by automatically extracting high-dimensional features from audio data. Specifically, a dual-branch model, combining the CNN model's ability to effectively capture the spatial features of audio spectrograms with the Transformer model's ability to capture long-range temporal dependencies in audio signals through a multi-head self-attention mechanism, was constructed. However, while the dual-branch model offers certain advantages in classification accuracy, it suffers from high computational complexity and a large number of parameters. These models often require high-performance GPUs or cloud computing resources for inference, making them unsuitable for real-time execution on resource-constrained mobile devices. Furthermore, the traditional Transformer model uses a global attention mechanism, resulting in computational complexity that increases with the square of the sequence length, making it difficult to meet real-time inference requirements. Furthermore, existing music genre classification models primarily extract features from audio data, neglecting the textual information of lyrics, which can reflect the stylistic characteristics of a song.

[0004] Therefore, there is an urgent need to provide a new audio classification method that takes into account both computational efficiency and classification accuracy, which can effectively reduce the computational cost and memory requirements of running music genre classification models in real time on mobile devices, while analyzing the semantic features of lyrics text while considering audio features to maintain a high classification accuracy and further improve the user experience. Summary of the Invention

[0005] In response to the problems in the existing technology in dealing with the diversity of music styles, the huge amount of audio data, and the high computational complexity of feature extraction, which lead to difficulties in real-time reasoning on mobile terminals, this application proposes a music genre classification method, device and readable medium based on a three-branch architecture to solve the above technical problems.

[0006] In a first aspect, the present invention provides a music genre classification method based on a three-branch architecture, comprising the following steps:

[0007] Constructing and training a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model, wherein the trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence, wherein the three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch set in parallel;

[0008] The audio data and corresponding lyrics text of the music to be classified are obtained and preprocessed respectively to obtain the corresponding logarithmic Mel-spectrogram and the preprocessed text sequence, the logarithmic Mel-spectrogram corresponding to the audio data and the preprocessed text sequence are input into the trained music genre classification model, the logarithmic Mel-spectrogram corresponding to the audio data is input into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer respectively to obtain local features and global features; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fused features; the fused features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

[0009] Preferably, the ConvNeXt-Tiny convolution branch includes a Stem layer, a first ConvNeXt unit, a first downsampling layer, a second ConvNeXt unit, a third ConvNeXt unit, a second downsampling layer, a fourth ConvNeXt unit and a first adaptive average pooling layer connected in sequence; the Stem layer includes a two-dimensional convolution layer with a convolution kernel size of 4×4 and a step size of 4, the first ConvNeXt unit includes 3 stacked ConvNeXt modules, the second ConvNeXt unit includes 9 stacked ConvNeXt modules, the third ConvNeXt unit includes 3 stacked ConvNeXt modules, and the fourth ConvNeXt unit includes 3 stacked ConvNeXt modules.

[0010] Preferably, the ConvNeXt module includes a depthwise separable convolutional layer, a first normalization layer, a first pointwise convolutional layer, a first GELU activation function layer, and a second pointwise convolutional layer connected in sequence;

[0011] The input features of the ConvNeXt module are input into the ConvNeXt module and first pass through the depth-wise separable convolution layer to obtain the first feature, as shown in the following formula:

[0012] ;

[0013] in, Represents the feature of the lth channel of the first feature, Represents the features of the lth channel of the input features of the ConvNeXt module, represents the convolution kernel of the lth channel, Represents the convolution operation;

[0014] The first feature is input to the first normalization layer, and then the channel dimension is expanded through the first point convolution layer with a convolution kernel size of 1×1. Then, nonlinearity is introduced through the first GELU activation function layer. Finally, the number of channels is restored using the second point convolution layer with a convolution kernel size of 1×1 to obtain the second feature, as shown in the following formula:

[0015] ;

[0016] in, Representation layer normalization operation, Represents a convolution operation with a convolution kernel size of 1×1, represents the GELU activation function, Represents the first feature, Indicates the second feature;

[0017] The second feature is added to the input feature of the ConvNeXt module through the residual connection to obtain the output feature of the ConvNeXt module, as shown in the following formula:

[0018] ;

[0019] The output features of the fourth ConvNeXt unit are input into the first adaptive average pooling layer for adaptive average pooling operation to obtain local features, as shown in the following formula:

[0020] ;

[0021] in, represents the output features of the fourth ConvNeXt unit, Represents local features, Represents an adaptive average pooling operation.

[0022] Preferably, the Performer branch includes six stacked Performer modules and a second adaptive average pooling layer; each Performer module includes a linear attention module, a second normalization layer, and a feedforward network layer, and the feedforward network layer includes a first fully connected layer, a second GELU activation function layer, and a second fully connected layer connected in sequence;

[0023] First, the input features of the Performer branch are patch-embedded to obtain the embedded features , and add the position code PE to get the coding feature , as shown below:

[0024] ;

[0025] The encoded features are input into the first Performer module, first as the input features of the linear attention module, and mapped into query vector, key vector and value vector, as shown in the following formula:

[0026] , , ;

[0027] in, 、 and are respectively learnable query weight, key weight and value weight, 、 and They are query vector, key vector and value vector respectively;

[0028] The attention matrix is ​​approximated by random feature mapping as shown below:

[0029] ;

[0030] in, represents the attention matrix, is a random feature mapping function, and its expression is as follows:

[0031] ;

[0032] Where m is the dimension of the feature map, W is the projection matrix randomly sampled from the Gaussian distribution, and x is the input vector of the random feature map function. represents the output vector of the random feature mapping function;

[0033] The attention matrix is ​​added to the input features of the linear attention module and then passed through the second normalization layer and the feedforward network layer, as shown in the following formula:

[0034] ;

[0035] in, Represents the output features of the first Performer module;

[0036] After 6 Performer modules, the output features of the 6th Performer module are obtained , the output features of the 6th Performer module Input to the second adaptive average pooling layer for adaptive average pooling operation to obtain the global features, as shown in the following formula:

[0037] ;

[0038] in, Represents global features, Represents an adaptive average pooling operation.

[0039] Preferably, the NLP text processing branch includes a word embedding layer, a position encoding layer, and an encoder, the word embedding layer includes a pre-trained BERT model, and the encoder includes a stacked 12-layer Transformer structure;

[0040] The preprocessed text sequence is first input into the word embedding layer and the position encoding layer respectively, and embedded into a vector representation to obtain the embedded text sequence, as shown in the following formula:

[0041] ;

[0042] in, Represents the preprocessed text sequence, represents the word embedding layer, represents the position encoding layer, Represents the embedded text sequence;

[0043] The embedded text sequence passes through the encoder to obtain an output sequence consisting of context representations, as shown in the following formula:

[0044] ;

[0045] in, is the context representation corresponding to the i-th Token in the preprocessed text sequence, and H represents the output sequence;

[0046] The output sequence is input into the average pooling layer for semantic aggregation processing to obtain text features, as shown in the following formula:

[0047] ;

[0048] in, is the average pooling operation, Represents text features.

[0049] Preferably, the local features, global features, and text features are input into a gated fusion layer to obtain fused features; the fused features are input into a classification layer to obtain a predicted audio genre category corresponding to the music to be classified, specifically including:

[0050] The gated fusion layer consists of a concatenation layer and three linear layers set in parallel;

[0051] Combine local features, global features and text features into , and input it into the gated fusion layer for feature fusion to obtain the fusion feature, as shown in the following formula:

[0052] ;

[0053] Among them, [] represents feature splicing, represents fusion features;

[0054] The fused features are input into three parallel linear layers to obtain the corresponding gating weights of local features, global features, and text features, as shown in the following formula:

[0055] ;

[0056] ;

[0057] ;

[0058] in, 、 and They are the gating weights of local features, global features and text features, 、 and is the weight matrix in the linear layer, 、 and is the bias term in the linear layer, is the Sigmoid activation function;

[0059] The gating weights of local features, global features, and text features are weighted and fused to obtain the fused features, as shown in the following formula:

[0060] ;

[0061] in, is element-wise multiplication, represents fusion features;

[0062] The classification layer includes the Dropout layer, the fully connected network, and the Softmax function layer;

[0063] The fused features first pass through the Dropout layer, then are mapped to the fully connected network, and finally pass through the Softmax function layer to obtain the predicted probability of each music genre, as shown in the following formula:

[0064] ;

[0065]

[0066] in, and is the weight matrix of the fully connected network, and is the bias term of the fully connected network, is the predicted probability of the cth genre, j is the index of all music genres, C represents the total number of music genres, represents the confidence score sequence, represents the confidence score corresponding to the cth music genre in the confidence score sequence;

[0067] The music genre corresponding to the maximum predicted probability is selected as the predicted audio genre category corresponding to the music to be classified.

[0068] In a second aspect, the present invention provides a music genre classification device based on a three-branch architecture, comprising:

[0069] a model building module configured to build and train a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model, wherein the trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence, wherein the three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch arranged in parallel;

[0070] The prediction module is configured to obtain the audio data and corresponding lyrics text of the music to be classified and preprocess them respectively to obtain the corresponding logarithmic Mel-spectrogram and the preprocessed text sequence, and input the logarithmic Mel-spectrogram corresponding to the audio data and the preprocessed text sequence into the trained music genre classification model. The logarithmic Mel-spectrogram corresponding to the audio data is respectively input into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer to obtain local features and global features; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fusion features; the fusion features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

[0071] In a third aspect, the present invention provides an electronic device comprising one or more processors; a storage device for storing one or more programs, wherein when the one or more programs are executed by one or more processors, the one or more processors implement the method described in any implementation manner in the first aspect.

[0072] In a fourth aspect, the present invention provides a computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the method described in any implementation manner in the first aspect.

[0073] In a fifth aspect, the present invention provides a computer program product, comprising a computer program, which implements the method described in any implementation manner in the first aspect when the computer program is executed by a processor.

[0074] Compared with the prior art, the present invention has the following beneficial effects:

[0075] (1) The music genre classification method based on the three-branch architecture proposed in this paper extracts the spatial information, temporal dependency information and lyrics semantic information of audio features by constructing an efficient convolutional network branch (ConvNeXt), a lightweight linear attention Performer branch and an NLP text processing branch, and integrates them in an efficient feature fusion manner, thereby achieving lightweight design and low-latency inference of the model.

[0076] (2) Compared with the traditional Transformer model, the music genre classification method based on the three-branch architecture proposed in the present invention reduces the complexity to linear, greatly improving the inference speed of mobile devices. Compared with the traditional CNN, the ConvNeXt module further reduces the parameter scale and computational load while maintaining the classification accuracy. Therefore, the present invention can significantly reduce the model calculation cost and improve the real-time inference performance and classification accuracy on mobile devices.

[0077] (3) The music genre classification method based on the three-branch architecture proposed in this paper adopts a gated fusion approach to perform three-branch feature fusion. The gate weights are dynamically adjusted according to the input features. This not only adapts to the data characteristics of different music genres, but also intuitively reflects the contribution of each branch, facilitating the analysis of model behavior. Utilizing this efficient feature fusion strategy, the output features of different branches are effectively integrated, further improving classification accuracy. The lightweight design of the overall model greatly reduces the model's storage and computational costs, making it more suitable for mobile applications. BRIEF DESCRIPTION OF THE DRAWINGS

[0078] In order to more clearly illustrate the technical solutions in the embodiments of the present invention, the following briefly introduces the drawings required for use in the description of the embodiments. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying any creative work.

[0079] Figure 1 Schematic diagram of the flow of a music genre classification method based on a three-branch architecture according to an embodiment of the present application;

[0080] Figure 2 A schematic diagram of a music genre classification model of a music genre classification method based on a three-branch architecture according to an embodiment of the present application;

[0081] Figure 3 Schematic diagram of the ConvNeXt-Tiny convolution branch of the music genre classification method based on the three-branch architecture according to an embodiment of the present application;

[0082] Figure 4 Schematic diagram of a ConvNeXt module of a music genre classification method based on a three-branch architecture according to an embodiment of the present application;

[0083] Figure 5 Schematic diagram of a Performer module of a music genre classification method based on a three-branch architecture according to an embodiment of the present application;

[0084] Figure 6 Schematic diagram of a music genre classification device based on a three-branch architecture according to an embodiment of the present application;

[0085] Figure 7 A schematic diagram of the hardware structure of an electronic device provided by an embodiment of the present invention. DETAILED DESCRIPTION

[0086] To make the objectives, technical solutions, and advantages of the present invention more apparent, the present invention will be further described in detail below with reference to the accompanying drawings. It is apparent that the embodiments described are only some, not all, of the present invention. All other embodiments derived by persons of ordinary skill in the art based on the embodiments of the present invention without creative effort are intended to fall within the scope of protection of the present invention.

[0087] Figure 1 A music genre classification method based on a three-branch architecture provided in an embodiment of the present application is shown, comprising the following steps:

[0088] S1. Construct and train a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model. The trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence. The three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch set in parallel.

[0089] Specifically, refer to Figure 2 The three-branch network layer in the music genre classification model proposed in the embodiments of this application uses a parallel ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch to extract local features, global features, and text features, respectively. These local, global, and text features are fed into a gated fusion layer for feature fusion, and then pass through a classification layer to obtain the corresponding predicted audio genre category.

[0090] Collect music from several different audio genres to form training data. The process of obtaining training data is as follows:

[0091] Collect raw audio data with true audio genre labels;

[0092] Perform random time-domain cropping on the original audio data to obtain several audio clips;

[0093] Randomly mix and add noise to each audio clip to obtain a noisy audio clip;

[0094] Perform time-frequency masking on the noisy audio clip to obtain enhanced audio data;

[0095] Convert the enhanced audio data into a log-mel spectrogram;

[0096] Collect lyrics text information, perform word segmentation, cleaning and tokenization, and obtain the corresponding token sequence;

[0097] The logarithmic Mel-spectrogram, Token sequence and its corresponding audio genre true label constitute the training data.

[0098] Specifically, when constructing the training data for the music genre classification model, the original audio data is first enhanced, including random time-domain cropping, random mixed noise addition, and time-frequency masking (SpecAugment). By significantly increasing the number of training data samples while maintaining the true audio genre labels, the model's adaptability to different timbres, noise environments, and music clips is improved. The specific steps are as follows:

[0099] (1) Random time domain cropping: The original audio data is sampled into segments of equal length, and the sampling rate (sr) is set to 22050 Hz. In one embodiment, a window of 3 seconds is randomly selected from the original audio data, and five non-overlapping random positions are selected within the window. , and intercept a length at each position , get several audio clips . The original audio data is recorded as , T' represents the maximum time of the original audio data, represents the set of real numbers, then:

[0100] ;

[0101] in, represents the ath audio segment, Represents a random position in the original audio data The length intercepted at the starting position is audio data, , , This process generates more training data samples while keeping the true labels of the audio genres unchanged.

[0102] (2) Random mixing and noise addition: After the audio segment is cut On the , different types or intensities of noise n are superimposed to form a noisy audio segment, as shown in the following formula:

[0103] ;

[0104] in, represents the a-th audio segment after adding noise, The noise intensity control parameter can be adjusted according to the noise type and target signal-to-noise ratio (SNR). This step can effectively improve the model's adaptability to various environmental noises.

[0105] (3) Time-frequency masking (SpecAugment): In order to simulate the similar effect of SpecAugment at the time domain waveform level, the time domain interval can be randomly selected , set the values ​​in the interval to 0. Mathematically, it can be expressed as:

[0106] ;

[0107] in, Indicates that the a-th enhanced audio data is in the The value at the time step, Indicates that the a-th noised audio segment is in The enhanced audio data contains multiple enhancement effects such as random cropping, noise addition, and time domain occlusion.

[0108] After the aforementioned enhancement processing is completed, in order to more effectively extract the time-frequency structural features in the audio data, the enhanced audio clips are further preprocessed and converted into corresponding logarithmic Mel-spectrograms, which serve as the primary representation of the model input. Specifically, a short-time Fourier transform (STFT) is applied to each enhanced audio clip to obtain its spectrogram, and the spectrogram is mapped into a Mel-spectrogram with 128-dimensional frequency bands based on a Mel-scale filter bank. The logarithm is then taken to obtain a logarithmic Mel-spectrogram to enhance the separability of the spectral features. Ultimately, all the enhanced and converted logarithmic Mel-spectrograms, token sequences, and their true audio genre labels constitute training data, which is used to train the music genre classification model to obtain a trained music genre classification model.

[0109] The training process of the music genre classification model in the embodiment of the present application adopts the cross entropy loss function, as shown in the following formula:

[0110]

[0111] Where N is the total number of samples in the training data, q represents the qth sample, c represents the cth audio genre category, and C represents the total number of audio genre categories. is the true label of the qth sample in the cth audio genre category, is the predicted probability of the qth sample in the cth audio genre category.

[0112] Specifically, the initial learning rate selected during model training is 1×10 -4 , use cosine annealing scheduling for optimization adjustment. The optimizer is AdamX, and the weight decay coefficient is 1×10 -2, the batch size is selected as 16, the total number of training rounds is 100, and the early stopping strategy is adopted. If there is no obvious performance improvement within 10 training steps, the training is stopped.

[0113] S2. Obtain the audio data and corresponding lyrics text of the music to be classified and preprocess them separately to obtain the corresponding logarithmic Mel-spectrogram and the preprocessed text sequence. Input the logarithmic Mel-spectrogram corresponding to the audio data and the preprocessed text sequence into the trained music genre classification model. The logarithmic Mel-spectrogram corresponding to the audio data is input into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer respectively to obtain local features and global features; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fusion features; the fusion features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

[0114] Specifically, the trained music genre classification model is deployed. During inference, the acquired audio data and corresponding lyrics of the music to be classified are preprocessed using the same preprocessing methods as described above. This yields a corresponding log-mel spectrogram and a preprocessed text sequence (i.e., a token sequence). The log-mel spectrogram and token sequence are then input into the trained music genre classification model.

[0115] In a specific embodiment, the ConvNeXt-Tiny convolution branch includes a Stem layer, a first ConvNeXt unit, a first downsampling layer, a second ConvNeXt unit, a third ConvNeXt unit, a second downsampling layer, a fourth ConvNeXt unit and a first adaptive average pooling layer connected in sequence; the Stem layer includes a two-dimensional convolution layer with a convolution kernel size of 4×4 and a stride of 4, the first ConvNeXt unit includes 3 stacked ConvNeXt modules, the second ConvNeXt unit includes 9 stacked ConvNeXt modules, the third ConvNeXt unit includes 3 stacked ConvNeXt modules, and the fourth ConvNeXt unit includes 3 stacked ConvNeXt modules.

[0116] In a specific embodiment, the ConvNeXt module includes a depthwise separable convolutional layer, a first normalization layer, a first pointwise convolutional layer, a first GELU activation function layer, and a second pointwise convolutional layer connected in sequence;

[0117] The input features of the ConvNeXt module are input into the ConvNeXt module and first pass through the depth-wise separable convolution layer to obtain the first feature, as shown in the following formula:

[0118] ;

[0119] in, Represents the feature of the lth channel of the first feature, Represents the features of the lth channel of the input features of the ConvNeXt module, represents the convolution kernel of the lth channel, Represents the convolution operation;

[0120] The first feature is input to the first normalization layer, and then the channel dimension is expanded through the first point convolution layer with a convolution kernel size of 1×1. Then, nonlinearity is introduced through the first GELU activation function layer. Finally, the number of channels is restored using the second point convolution layer with a convolution kernel size of 1×1 to obtain the second feature, as shown in the following formula:

[0121] ;

[0122] in, Representation layer normalization operation, Represents a convolution operation with a convolution kernel size of 1×1, represents the GELU activation function, Represents the first feature, Indicates the second feature;

[0123] The second feature is added to the input feature of the ConvNeXt module through the residual connection to obtain the output feature of the ConvNeXt module, as shown in the following formula:

[0124] ;

[0125] The output features of the fourth ConvNeXt unit are input into the first adaptive average pooling layer for adaptive average pooling operation to obtain local features, as shown in the following formula:

[0126] ;

[0127] in, represents the output features of the fourth ConvNeXt unit, Represents local features, Represents an adaptive average pooling operation.

[0128] Specifically, refer to Figure 3The logarithmic Mel-spectrogram corresponding to the input audio data is processed by the Stem layer, which consists of a single layer of two-dimensional convolution with a kernel size of 4×4 and a stride of 4. The main function of the Stem layer is to reduce the size of the feature map and extract preliminary features. The output features of the Stem layer are input to the first ConvNeXt unit and processed in sequence by three serially connected ConvNeXt modules. The output features of the first ConvNeXt unit are processed by the first downsampling layer to reduce the feature map size and increase the number of channels. The downsampled features are then passed through the three ConvNeXt modules of the second ConvNeXt unit.

[0129] Next, the features are fed directly into the third ConvNeXt unit, a deep cascade structure consisting of nine ConvNeXt modules with the same number of channels. The third ConvNeXt unit is the backbone of the music genre classification model, containing the largest number of ConvNeXt modules and capable of extracting more complex and abstract feature representations. Due to the demands of low-performance mobile devices, nine ConvNeXt modules were chosen to form the backbone. The output features of the third ConvNeXt unit are then processed by the second downsampling layer. Finally, the downsampled features are passed through the three ConvNeXt modules of the fourth ConvNeXt unit. After all ConvNeXt modules have been processed, the feature maps are converted into feature vectors through adaptive average pooling to obtain local features.

[0130] For further reference, Figure 4 , the ConvNeXt module uses a depthwise separable convolution module to efficiently capture the spatial features in the logarithmic Mel-spectrogram to obtain the first feature. The first feature first passes through the first normalization (LayerNorm) layer, and then passes through the first point convolution layer with a convolution kernel size of 1×1 to expand the channel dimension, and then introduces nonlinearity through the first GELU activation function layer. Finally, another second point convolution layer with a convolution kernel size of 1×1 is used to restore the number of channels to obtain the second feature. After that, the second feature is added to the input feature of the ConvNeXt module through a residual connection to obtain the output feature of the ConvNeXt module. In several stacked ConvNeXt modules, the output feature of the previous ConvNeXt module is input to the next ConvNeXt module and the above calculation process is repeated. The output feature of the third ConvNeXt module of the fourth ConvNeXt unit is the output feature of the fourth ConvNeXt unit. The output features of the fourth ConvNeXt unit are Finally, after the first adaptive average pooling layer, the local features are finally obtained.

[0131] In a specific embodiment, the Performer branch includes six stacked Performer modules and a second adaptive average pooling layer; each Performer module includes a linear attention module, a second normalization layer, and a feedforward network layer, and the feedforward network layer includes a first fully connected layer, a second GELU activation function layer, and a second fully connected layer connected in sequence;

[0132] First, the input features of the Performer branch are patch-embedded to obtain the embedded features , and add the position code PE to get the coding feature , as shown below:

[0133] ;

[0134] The encoded features are input into the first Performer module, first as the input features of the linear attention module, and mapped into query vector, key vector and value vector, as shown in the following formula:

[0135] , , ;

[0136] in, 、 and are respectively learnable query weight, key weight and value weight, 、 and They are query vector, key vector and value vector respectively;

[0137] The attention matrix is ​​approximated by random feature mapping as shown below:

[0138] ;

[0139] in, represents the attention matrix, is a random feature mapping function, and its expression is as follows:

[0140] ;

[0141] Where m is the dimension of the feature map, W is the projection matrix randomly sampled from the Gaussian distribution, and x is the input vector of the random feature map function. represents the output vector of the random feature mapping function;

[0142] The attention matrix is ​​added to the input features of the linear attention module and then passed through the second normalization layer and the feedforward network layer, as shown in the following formula:

[0143] ;

[0144] in, Represents the output features of the first Performer module;

[0145] After 6 Performer modules, the output features of the 6th Performer module are obtained , the output features of the 6th Performer module Input to the second adaptive average pooling layer for adaptive average pooling operation to obtain the global features, as shown in the following formula:

[0146] ;

[0147] in, Represents global features, Represents an adaptive average pooling operation.

[0148] Specifically, the Performer branch uses a linear attention mechanism to achieve lightweight Transformer structure, refer to Figure 5 The Performer branch consists of 6 stacked Performer modules and a second adaptive average pooling layer. The linear attention module is used in the Performer module, that is, through the random feature map (kernel function ) Approximately calculate the attention matrix, reducing the computational complexity of the attention mechanism from the original down to , significantly reducing computational costs and memory consumption, making it suitable for real-time inference scenarios on mobile devices. The features obtained after the six Performer modules are passed through the second adaptive average pooling layer to obtain global features.

[0149] In a specific embodiment, the NLP text processing branch includes a word embedding layer, a position encoding layer, and an encoder, the word embedding layer includes a pre-trained BERT model, and the encoder includes a stacked 12-layer Transformer structure;

[0150] The preprocessed text sequence is first input into the word embedding layer and the position encoding layer respectively, and embedded into a vector representation to obtain the embedded text sequence, as shown in the following formula:

[0151] ;

[0152] in, Represents the preprocessed text sequence, represents the word embedding layer, represents the position encoding layer, Represents the embedded text sequence;

[0153] The embedded text sequence passes through the encoder to obtain an output sequence consisting of context representations, as shown in the following formula:

[0154] ;

[0155] in, is the context representation corresponding to the i-th Token in the preprocessed text sequence, and H represents the output sequence;

[0156] The output sequence is input into the average pooling layer for semantic aggregation processing to obtain text features, as shown in the following formula:

[0157] ;

[0158] in, is the average pooling operation, Represents text features.

[0159] Specifically, the NLP text processing branch extracts semantic features from the lyrics. The token sequence generated after preprocessing the lyrics is fed into a pretrained BERT model to obtain contextual semantic vectors. This is then positionally encoded to produce an embedded text sequence. The embedded text sequence then passes through an encoder consisting of 12 Transformer layers to obtain a contextual representation of each token, forming the output sequence H. This output sequence H is then semantically aggregated to produce fixed-dimensional text features.

[0160] In a specific embodiment, local features, global features, and text features are input into a gated fusion layer to obtain fused features; the fused features are input into a classification layer to obtain a predicted audio genre category corresponding to the music to be classified, specifically including:

[0161] The gated fusion layer consists of a concatenation layer and three linear layers set in parallel;

[0162] Combine local features, global features and text features into , and input it into the gated fusion layer for feature fusion to obtain the fusion feature, as shown in the following formula:

[0163] ;

[0164] Among them, [] represents feature splicing, represents fusion features;

[0165] The fused features are input into three parallel linear layers to obtain the corresponding gating weights of local features, global features, and text features, as shown in the following formula:

[0166] ;

[0167] ;

[0168] ;

[0169] in, 、 and They are the gating weights of local features, global features and text features, 、 and is the weight matrix in the linear layer, 、 and is the bias term in the linear layer, is the Sigmoid activation function;

[0170] The gating weights of local features, global features, and text features are weighted and fused to obtain the fused features, as shown in the following formula:

[0171] ;

[0172] in, is element-wise multiplication, represents fusion features;

[0173] The classification layer includes the Dropout layer, the fully connected network, and the Softmax function layer;

[0174] The fused features first pass through the Dropout layer, then are mapped to the fully connected network, and finally pass through the Softmax function layer to obtain the predicted probability of each music genre, as shown in the following formula:

[0175] ;

[0176]

[0177] in, and is the weight matrix of the fully connected network, and is the bias term of the fully connected network, is the predicted probability of the cth genre, j is the index of all music genres, C represents the total number of music genres, represents the confidence score sequence, represents the confidence score corresponding to the cth music genre in the confidence score sequence; represents the confidence score corresponding to the jth music genre in the confidence score sequence;

[0178] The music genre corresponding to the maximum predicted probability is selected as the predicted audio genre category corresponding to the music to be classified.

[0179] Specifically, the local features output by the ConvNeXt branch, the global features output by the Performer branch, and the text features output by the NLP text processing branch are input into the gated fusion layer and first concatenated into And further fusion is performed. The concatenated features are input into three separate linear layers to obtain the gating weights of local features, global features, and text features respectively. The corresponding features are weightedly fused using the gating weights to obtain the final fused features. The gating weights are dynamically adjusted according to the input features and can adapt to the data characteristics of different music genres (for example, some genres rely more on lyrics, while others rely more on melody). In addition, the gating weights can intuitively reflect the contribution of each branch, making it easier to analyze model behavior. The fused features are input into the classification layer, mapped through the Dropout layer and the fully connected network, and finally passed through the Softmax function layer to obtain the predicted probability distribution of each music genre. The final music genre prediction category is the music genre with the highest probability.

[0180] Further references Figure 6 As an implementation of the methods shown in the above figures, the present application provides an embodiment of a music genre classification device based on a three-branch architecture. Figure 1 Corresponding to the method embodiment shown, the device can be specifically applied to various electronic devices.

[0181] The present embodiment provides a music genre classification device based on a three-branch architecture, comprising:

[0182] A model construction module 1 is configured to construct and train a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model, wherein the trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence, wherein the three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch arranged in parallel;

[0183] Prediction module 2 is configured to obtain the audio data and corresponding lyrics text of the music to be classified and preprocess them respectively to obtain the corresponding logarithmic Mel-spectrogram and the preprocessed text sequence, and input the logarithmic Mel-spectrogram corresponding to the audio data and the preprocessed text sequence into the trained music genre classification model. The logarithmic Mel-spectrogram corresponding to the audio data is respectively input into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer to obtain local features and global features; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fusion features; the fusion features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

[0184] Figure 7 Schematic diagram of the hardware structure of the electronic device provided by the embodiment of the present invention. Figure 7 As shown, the electronic device of this embodiment includes: a processor 701 and a memory 702; wherein the memory 702 is used to store computer-executable instructions; and the processor 701 is used to execute the computer-executable instructions stored in the memory to implement the various steps performed by the electronic device in the above embodiment. For details, please refer to the relevant description of the above method embodiment.

[0185] Optionally, the memory 702 may be independent or integrated with the processor 701 .

[0186] When the memory 702 is independently provided, the electronic device further includes a bus 703 for connecting the memory 702 and the processor 701 .

[0187] An embodiment of the present invention further provides a computer storage medium, in which computer execution instructions are stored. When the processor 701 executes the computer execution instructions, the above method is implemented.

[0188] An embodiment of the present invention further provides a computer program product, including a computer program. When the computer program is executed by the processor 701, the above method is implemented.

[0189] In the embodiments provided herein, it should be understood that the disclosed devices and methods can be implemented in other ways. For example, the device embodiments described above are merely illustrative. For example, the module division is merely a logical functional division. In actual implementation, other division methods may be used. For example, multiple modules may be combined or integrated into another system, or some features may be ignored or not implemented. In addition, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection through some interface, device or module, which may be electrical, mechanical or other forms.

[0190] Modules described as separate components may or may not be physically separate, and components shown as modules may or may not be physical units, that is, they may be located in one place or distributed across multiple network elements. Some or all of these modules may be selected to implement the solution of this embodiment based on actual needs.

[0191] In addition, the functional modules in various embodiments of the present invention may be integrated into a single processing unit, each module may exist physically separately, or two or more modules may be integrated into a single unit. The units formed by the above modules may be implemented in the form of hardware or hardware plus software functional units.

[0192] The above-mentioned integrated module implemented in the form of a software function module can be stored in a computer-readable storage medium. The above-mentioned software function module is stored in a storage medium and includes a number of instructions for causing a computer device (which can be a personal computer, server, or network device, etc.) or processor 701 to perform some steps of the methods of various embodiments of the present application.

[0193] It should be understood that the processor 701 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), or application-specific integrated circuits (ASIC). A general-purpose processor may be a microprocessor, or the processor 701 may be any conventional processor 701. The steps of the method disclosed in the present invention may be directly implemented by the hardware processor 701, or implemented by a combination of hardware and software modules in the processor 701.

[0194] The memory 702 may include a high-speed RAM memory, and may also include a non-volatile storage NVM, such as at least one disk memory, and may also be a USB flash drive, a mobile hard disk, a read-only memory, a magnetic disk, or an optical disk.

[0195] Bus 703 can be an Industry Standard Architecture (ISA), a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus. Bus 703 can be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, the bus 703 in the drawings of this application is not limited to only one bus 703 or only one type of bus 703.

[0196] The storage medium may be implemented by any type of volatile or non-volatile memory device, or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The storage medium may be any available medium that can be accessed by a general-purpose or special-purpose computer.

[0197] An exemplary storage medium is coupled to the processor 701, so that the processor 701 can read information from the storage medium and write information to the storage medium. Of course, the storage medium can also be an integral part of the processor 701. The processor 701 and the storage medium can be located in an application-specific integrated circuit (ASIC). Of course, the processor 701 and the storage medium can also exist as discrete components in an electronic device or a main control device.

[0198] Those skilled in the art will appreciate that all or part of the steps in the above-described method embodiments can be implemented using hardware associated with program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments. The aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.

[0199] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the above embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the above embodiments, or replace some or all of the technical features therein with equivalents. However, these modifications or replacements do not cause the essence of the corresponding technical solutions to deviate from the scope of the technical solutions of the embodiments of the present invention.

Claims

1. A music genre classification method based on a three-branch architecture, characterized in that: The following steps are involved: Constructing and training a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model, wherein the trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence, wherein the three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch arranged in parallel; Acquire audio data and corresponding lyrics text of the music to be classified and preprocess them respectively to obtain corresponding logarithmic Mel-spectrograms and preprocessed text sequences, input the logarithmic Mel-spectrograms corresponding to the audio data and the preprocessed text sequences into the trained music genre classification model, and input the logarithmic Mel-spectrograms corresponding to the audio data into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer respectively to obtain local features and global features, the Performer branch includes 6 stacked Performer modules and a second adaptive average pooling layer; each Performer module includes a linear attention module, a second normalization layer and a feedforward network layer, and the feedforward network layer includes a first fully connected layer, a second GELU activation function layer and a second fully connected layer connected in sequence; First, the input features of the Performer branch are patch-embedded to obtain the embedded features X embeded , and add the position encoding PE to get the encoding feature X pe , as shown below: X pe =X embeded +PE; The encoded features are input into the first Performer module as input features of the linear attention module and mapped into query vector, key vector and value vector as shown in the following formula: Q=X pe W Q ,K=X pe W K ,V=X pe W V ; Among them, W Q 、W K and W V are the learnable query weight, key weight, and value weight, respectively. Q, K, and V are the query vector, key vector, and value vector, respectively. The attention matrix is ​​approximated by random feature mapping as shown below: Attention(Q,K,V)=φ(Q)(φ(K) T V); Where Attention(Q,K,V) represents the attention matrix and φ(·) is the random feature mapping function, which is expressed as follows: Where m is the dimension of the feature map, W is the projection matrix randomly sampled from the Gaussian distribution, x is the input vector of the random feature map function, and φ(x) represents the output vector of the random feature map function; The attention matrix is ​​added to the input features of the linear attention module and then passed through the second normalization layer and the feedforward network layer, as shown in the following formula: X performer,1 =FFN(LayerNorm(Attention(Q,K,V)+X pe )); Among them, X performer,1 Represents the output features of the first Performer module; After 6 Performer modules, the output feature X of the 6th Performer module is obtained performer,6 , the output feature X of the 6th Performer module performer,6 Input to the second adaptive average pooling layer for adaptive average pooling operation to obtain the global features, as shown in the following formula: X global =AdaptiveAvgPool(X performer,6 ); Among them, X global Represents global features, AdaptiveAvgPool represents an adaptive average pooling operation; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fusion features; the fusion features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

2. The music genre classification method based on the three-branch architecture according to claim 1 is characterized in that: The ConvNeXt-Tiny convolution branch includes a Stem layer, a first ConvNeXt unit, a first downsampling layer, a second ConvNeXt unit, a third ConvNeXt unit, a second downsampling layer, a fourth ConvNeXt unit and a first adaptive average pooling layer connected in sequence; the Stem layer includes a two-dimensional convolution layer with a convolution kernel size of 4×4 and a step size of 4, the first ConvNeXt unit includes 3 stacked ConvNeXt modules, the second ConvNeXt unit includes 9 stacked ConvNeXt modules, the third ConvNeXt unit includes 3 stacked ConvNeXt modules, and the fourth ConvNeXt unit includes 3 stacked ConvNeXt modules.

3. The music genre classification method based on the three-branch architecture according to claim 2 is characterized in that: The ConvNeXt module includes a depth-wise separable convolutional layer, a first normalization layer, a first point convolutional layer, a first GELU activation function layer, and a second point convolutional layer connected in sequence; The input features of the ConvNeXt module are input into the ConvNeXt module and first pass through the depthwise separable convolution layer to obtain the first feature, as shown in the following formula: in, represents the feature of the lth channel of the first feature, Represents the features of the lth channel of the input features of the ConvNeXt module, represents the convolution kernel of the lth channel, Represents the convolution operation; The first feature is input to the first normalization layer, and then the channel dimension is expanded through the first point convolution layer with a convolution kernel size of 1×1. Then, nonlinearity is introduced through the first GELU activation function layer. Finally, the number of channels is restored using the second point convolution layer with a convolution kernel size of 1×1 to obtain the second feature, as shown in the following formula: X conv =Conv 1×1 (GELU(Conv 1×1 (LayerNorm(X dw )))); Among them, LayerNorm represents the layer normalization operation, Conv 1×1 represents a convolution operation with a convolution kernel size of 1×1, GELU represents the GELU activation function, and X dw represents the first feature, X conv Indicates the second feature; The second feature is added to the input feature of the ConvNeXt module through a residual connection to obtain the output feature of the ConvNeXt module, as shown in the following formula: X res =X in +X conv ; The output features of the fourth ConvNeXt unit are input into the first adaptive average pooling layer for adaptive average pooling operation to obtain local features, as shown in the following formula: X local =AdaptiveAvgPool(X convnext ); Among them, X convnext represents the output features of the fourth ConvNeXt unit, X local Represents local features, and AdaptiveAvgPool represents the adaptive average pooling operation.

4. The music genre classification method based on the three-branch architecture according to claim 1 is characterized in that: The NLP text processing branch includes a word embedding layer, a position encoding layer, and an encoder. The word embedding layer includes a pre-trained BERT model, and the encoder includes a stacked 12-layer Transformer structure. The preprocessed text sequence is first input into the word embedding layer and the position encoding layer respectively, and embedded into a vector representation to obtain the embedded text sequence, as shown in the following formula: E=Embed(T seq )+PosEmbed(T seq ); Among them, T seq Represents the preprocessed text sequence, Embed represents the word embedding layer, PosEmbed represents the position encoding layer, and E represents the embedded text sequence; The embedded text sequence passes through the encoder to obtain an output sequence consisting of context representations, as shown in the following formula: H=TransformerEncoder(E)={h1,h2,...,h n }; Among them, h i is the context representation corresponding to the i-th Token in the preprocessed text sequence, i = 1, 2, ..., n, H represents the output sequence; The output sequence is input into the average pooling layer for semantic aggregation processing to obtain text features, as shown in the following formula: X text =Pooling(H); Among them, Pooling is the average pooling operation, X text Represents text features.

5. The music genre classification method based on the three-branch architecture according to claim 1 is characterized in that: Inputting the local features, global features, and text features into a gated fusion layer to obtain fused features; inputting the fused features into a classification layer to obtain a predicted audio genre category corresponding to the music to be classified, specifically including: The gated fusion layer includes a splicing layer and three linear layers arranged in parallel; The local features, global features and text features are spliced ​​into X concat , and input it into the gated fusion layer for feature fusion to obtain the fusion feature, as shown in the following formula: X concat =[X local ,X global ,X text ]; Among them, [] represents feature concatenation, X concat represents fusion features; The fused features are input into three parallel linear layers to obtain the corresponding gating weights of local features, global features, and text features, as shown in the following formula: Among them, G local , G global and G text They are the gating weights of local features, global features and text features, and are the weight matrices of the linear layer corresponding to local features, the weight matrices of the linear layer corresponding to global features, and the weight matrices of the linear layer corresponding to text features, respectively. and are the bias items of the linear layer corresponding to local features, the bias items of the linear layer corresponding to global features, and the bias items of the linear layer corresponding to text features, respectively. Sigmoid is the Sigmoid activation function; The gating weights of the local features, the gating weights of the global features, and the gating weights of the text features are weightedly fused to obtain a fused feature, as shown in the following formula: X fusion =G local ⊙X local +G global ⊙X global +G text ⊙X text ; Among them, ⊙ is element-by-element multiplication, X fusion represents fusion features; The classification layer includes a Dropout layer, a fully connected network and a Softmax function layer; The fusion features first pass through the Dropout layer, then are mapped to the fully connected network, and finally pass through the Softmax function layer to obtain the predicted probability of each music genre, as shown in the following formula: H'=(ReLU((Dropout(X fusion ))W1+b1))W2+b2; Where W1 and W2 are the weight matrices of the fully connected network, b1 and b2 are the bias terms of the fully connected network, and p c is the predicted probability of the cth genre, j is the index of all music genres, C represents the total number of music genres, H' represents the confidence score sequence, H' c represents the confidence score corresponding to the cth music genre in the confidence score sequence, H' j represents the confidence score corresponding to the j-th music genre in the confidence score sequence; The music genre corresponding to the maximum predicted probability is selected as the predicted audio genre category corresponding to the music to be classified.

6. A music genre classification device based on a three-branch architecture, characterized in that: include: a model construction module configured to construct and train a music genre classification model based on a three-branch architecture to obtain a trained music genre classification model, wherein the trained music genre classification model includes a three-branch structure network layer, a gated fusion layer, and a classification layer connected in sequence, wherein the three-branch structure network layer includes a ConvNeXt-Tiny convolution branch, a Performer branch, and an NLP text processing branch arranged in parallel; A prediction module is configured to obtain audio data and corresponding lyrics text of music to be classified and preprocess them respectively to obtain corresponding logarithmic Mel-spectrograms and preprocessed text sequences, input the logarithmic Mel-spectrograms corresponding to the audio data and the preprocessed text sequences into the trained music genre classification model, and input the logarithmic Mel-spectrograms corresponding to the audio data into the ConvNeXt-Tiny convolution branch and the Performer branch in the three-branch structure network layer to obtain local features and global features, wherein the Performer branch includes 6 stacked Performer modules and a second adaptive average pooling layer; each Performer module includes a linear attention module, a second normalization layer and a feedforward network layer, and the feedforward network layer includes a first fully connected layer, a second GELU activation function layer and a second fully connected layer connected in sequence; First, the input features of the Performer branch are patch-embedded to obtain the embedded features X embeded , and add the position encoding PE to get the encoding feature X pe , as shown below: X pe =X embeded +PE; The encoded features are input into the first Performer module as input features of the linear attention module and mapped into query vector, key vector and value vector as shown in the following formula: Q=X pe W Q ,K=X pe W K ,V=X pe W V ; Among them, W Q 、W K and W V are the learnable query weight, key weight, and value weight, respectively. Q, K, and V are the query vector, key vector, and value vector, respectively. The attention matrix is ​​approximated by random feature mapping as shown below: Attention(Q,K,V)=φ(Q)(φ(K) T V); Where Attention(Q,K,V) represents the attention matrix and φ(·) is the random feature mapping function, which is expressed as follows: Where m is the dimension of the feature map, W is the projection matrix randomly sampled from the Gaussian distribution, x is the input vector of the random feature map function, and φ(x) represents the output vector of the random feature map function; The attention matrix is ​​added to the input features of the linear attention module and then passed through the second normalization layer and the feedforward network layer, as shown in the following formula: X performer,1 =FFN(LayerNorm(Attention(Q,K,V)+X pe )); Among them, X performer,1 Represents the output features of the first Performer module; After 6 Performer modules, the output feature X of the 6th Performer module is obtained performer,6 , the output feature X of the 6th Performer module performer,6 Input to the second adaptive average pooling layer for adaptive average pooling operation to obtain the global features, as shown in the following formula: X global =AdaptiveAvgPool(X performer,6 ); Among them, X global Represents global features, AdaptiveAvgPool represents an adaptive average pooling operation; the preprocessed text sequence is input into the NLP text processing branch to obtain text features; the local features, global features and text features are input into the gated fusion layer to obtain fusion features; the fusion features are input into the classification layer to obtain the predicted audio genre category corresponding to the music to be classified.

7. An electronic device comprising: one or more processors; a storage device for storing one or more programs, When the one or more programs are executed by the one or more processors, the one or more processors implement the method according to any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

9. A computer program product comprising a computer program, characterized in that When the computer program is executed by a processor, the method according to any one of claims 1 to 5 is implemented.

Citation Information

Patent Citations

  • Attention-based audio and lyric multi-mode music style classification method

    CN113177136A

  • Music genre classification method based on CNN and Transform double-flow architecture

    CN118098271A