# Music Genre Classification Algorithm Based on Multihead Attention Mechanism

Authors: Peng Cheng
Journal: Advances in Multimedia
 (2022)

---

## Abstract

Retrieving music information is indispensable and divided into multiple genres. Music genres can be attributed to set categories, which are the indispensable functions of intelligent music recommendation systems. To improve the effect of music genre classification and model construction, combined with the music genre classification algorithm, this paper combines the multihead attention mechanism to study the music genre classification algorithm model, and it analyzes the key technology of music beamforming. Moreover, this paper has made a detailed description and derivation of the array antenna model, the principle of music beamforming, and the performance evaluation criteria of music adaptive beamforming. In the second half, the nonblind classical LMS algorithm, RLS algorithm, and variable step size LMS algorithm of adaptive beamforming are studied in detail. A music genre classification algorithm model based on the multihead attention mechanism is constructed. It can be seen from the experimental research that the music genre classification algorithm based on the multihead attention mechanism proposed in this paper has obvious advantages compared with the traditional algorithm, and it has a certain role in music genre classification.


---

## Body

## 1. Introduction

Music genre classification is a promising and challenging research work in the field of music information retrieval. Multicore learning is a new hotspot in the field of machine learning at present, and it is an effective method to solve a series of problems, such as data heterogeneity and uneven data distribution in nonlinear pattern analysis.Popular music mainly originated in the United States at the end of the nineteenth century, and from the perspective of the music system, popular music is mainly jazz, rock, blues, and so on. The style and the form of popular music in the country are mainly influenced by Europe and the United States, and on this basis, local music has gradually formed. In recent years, popular music has taken a Chinese style, and the style of music varies among musicians. It mainly uses pop music to approach the elements of Chinese traditional music, so that pop music has a unique style of our country. The elements of popular music in the country are also gradually increasing, such as the emergence of opera and classical elements in popular music, which promotes the better development of popular music in the country.Music genre classification is a promising and challenging research work in the field of music information retrieval, and multicore learning is a new hotspot in the field of machine learning, and it is also an effective method to solve a series of problems such as distribution.To improve the effect of music genre classification and model construction, combined with the music genre classification algorithm, this paper combines the multihead attention mechanism to study the music genre classification algorithm model, and it analyzes the key technology of music beamforming.The main organizational structure of this paper is as follows: the first part is the introduction part, which summarizes the background, motivation, literature review, and chapter arrangement. The second part is mainly the literature review part, which summarizes the related work and introduces the research content of this paper. The third part studies the music genre classification algorithm and propose the improved algorithm of this paper. The fourth part is to construct the music genre classification algorithm model based on the multihead attention mechanism and verify the model through experimental research. The fifth part is the research content of this paper.The main contribution of this paper is to improve the traditional algorithm and propose a music genre classification algorithm based on the multihead attention mechanism to improve the accuracy of music genre classification.This paper combines the multihead attention mechanism to study the music genre classification algorithm model to improve the music genre classification effect.


## 2. Related Work

Traditional classification methods represented by support vector machines, K-nearest neighbors, Gaussian mixture distribution models, etc., have been widely used in audio classification, and they achieved good results. However, with the improvement of computing power and the advancement of computing technology, various attributes, including audio, MIDI files, contextual scenes, etc., have been applied to the automatic classification of music genres, and they try to improve the classification accuracy [1]. In fact, too many attributes make the calculation process of classification too complicated, and it may lead to the decrease of classification accuracy. In addition, some single attributes show different classification effects for different music genres. For example, the attribute describing the intensity of percussion can distinguish well between classical and pop music but not for the subcategory of chamber music [2]. The literature [3] uses a hierarchical structure-based classification method to complete the automatic classification of the music of different genres. The difference between the hierarchical structure classification method and the traditional flat classification method lies in the hierarchical relationship of its structure. The hierarchical structure reduces the computational complexity on the premise of ensuring the classification accuracy by deploying features into different levels. Similar to other classification methods, hierarchical classification methods also include several steps, such as feature extraction, data preprocessing, and automatic classification. However, the difference lies in the need to combine the different classification effects of different attributes based on the existing data in advance to construct a hierarchical model with a specific hierarchical structure and guarantee the classification effect [4]. The music genre automatic classification method proposed in [5] is based on related music features, including MFCC. It combines the supervised classification method and adopts a hierarchical structure classification model to complete the automatic classification of music genres. This method is a hierarchical structure-based model built on the basis of the traditional flat model by combining the statistical attributes of the different genres of music and the different classification effects of a single attribute in different data subsets. The categorical features used in the model come from different levels of consideration. The first layer is mainly based on the core characteristics of music and is combined with its statistical properties. The statistical attributes mainly focus on the mean, standard deviation, and median. For single-value attributes, the value itself is used without any further processing. The second layer and the following layers use various attributes with better classification effects based on music genres to complete the classification of different subdatasets [6].In music classification, the single feature method can better solve the intuitive classification types, such as music types and musical instruments, however, for complex music emotion classification, a single feature can easily lead to the better recognition of some emotions and poor recognition of others. In a good situation, in response to this problem, the literature [7] used the method of combining the MFCC in the timbre feature and the pitch frequency, formant, and frequency band energy distribution in the prosody feature, which performed well in music emotion classification. As a characteristic of musical emotional expression.With the development of modern network, the scale of digital music continues to increase. Hence, music retrieval technology (MIR) has received more attention, and music emotion classification, as the most basic problem in many related fields of music, has received more attention as well [8]. For music emotion classification, the most common method is to analyze the acoustic features extracted from music to obtain emotion classification results. However, the classification effect achieved by this single modality alone is usually not satisfactory. Lyrics are the textual expression part of music songs, which contain the emotional sustenance of the songwriter. Hence, the analysis of the lyrics will also have a certain auxiliary effect on the emotional classification of music [9]. In addition, in the selection of classifiers based on music content, some shallow classifiers, such as k-NN, SVM, Bayesian, etc., are the commonly used classifiers for music emotion classification. Artificial neural networks, regression analysis, self-organizing maps, etc., are also widely used in this field [10], however, the classification results achieved by these classifiers cannot meet people's normal needs very well. Literature [11] proposed a dual-modal fusion music emotion classification algorithm based on the deep belief network (DBN) to improve the classification accuracy.Music genre classification is an important part of multimedia applications. With the rapid development of data storage, compression technology, and internet technology, music type data has increased dramatically [12]. In practical applications, the primary task of all commercial music databases and mp3 music download sites is to collect this music into the databases of different music types. Traditional manual retrieval methods can no longer satisfy the retrieval and classification of massive information [13]. It can use the acoustic characteristics of music itself to automatically classify it, instead of manual methods. Determining the type of background music is also an effective way to retrieve video scenes. Essentially, music type classification is a pattern recognition problem, which mainly includes two aspects: feature extraction and classification. Many researchers have done a lot of work in this area using different audio features and classification methods [14]. Literature [15] uses a Gaussian mixture model to classify 13 types of music in MPEG format. Literature [16] used KNN and GMM classifiers and wavelet features to classify music genres with error rates of 38% and 36%, respectively. Although the traditional parameters have achieved good results in practice, the robustness, adaptability, and generalization ability of these methods are limited, especially the characteristic parameters are mostly obtained by the analysis method of short-term stationary signals. The wavelet theory is a nonflat. The analysis method of a stable signal adopts the idea of ​​a multiresolution analysis and nonuniform division of time and frequency. It is a very effective tool in the time-frequency domain analysis and is widely used [17]. SVM is a new machine learning method developed on the basis of the statistical theory. It still maintains a good generalization ability under condition F of small samples. Based on the principle of structural risk minimization, the optimal classification hyperplane is established, which overcomes the shortcomings of the traditional rule-based classification algorithm.Music classification is essentially a pattern recognition process, and the processing process of music classification should conform to the general processing process of pattern recognition applications. Therefore, the idea of pattern recognition can be used to design the technical process of music classification. The music data for training and testing must first be collected. The selected features and models are determined according to the characteristics of the collected data, and then the classifier is trained, and the system parameters are determined. Finally, a satisfactory classifier is obtained using multiple test evaluation cycles [18].The choice of classifier is the key to music classification, and its performance directly determines the accuracy of music classification. Because of the diversity, uncertainty, and mass characteristics of music, the traditional classification method has a small amount of calculation and a slow speed, which can no longer satisfy the classification of mass music, and the classification accuracy rate is unsatisfactory. Therefore, the classifier must be selected according to the particularity of music classification. The BP neural network reflects the basic characteristics of the human brain function, and it has the ability of self-organization, adaptability, and continuous learning. The network is trainable, which can change its own performance with the accumulation of experience. The neural network processing data also has a high degree of parallelism. It can make fast judgments and is fault-tolerant, especially suitable for solving difficult-to-use problems, such as music classification. The algorithm describes the problem with a large number of samples for learning [19].


## 3. Music Waveform Recognition Analysis

### 3.1. Antenna Model

In the array antenna technology, we assume that a signal has a bandwidth ofWB and a center frequency of f0. If the ratio of bandwidth to center frequency is much less than 1,(1)WBf0≪1.Then, the signal is a narrowband signal.The expression after the signalst, whose center frequency is f0, reaches the antenna array is as follows:(2)st=utej2πf0t+vt.Among them,ut is the amplitude modulation function, and vt is the phase modulation function. At the same time, the influence of delay also needs to be considered in the array antenna technology, and the delay of the target signal is assumed to be r.(3)st−τ=ut−τej2πf0t−τ+vt−τ.If the target signalst is a narrowband signal, then ut and vt change less with time, and when z is small, it can become the following:(4)st−τ≈ste−j2πf0t.To sum up, for narrowband signals, the small delay has little effect on the amplitude, and it only produces some phase changes. The research in this paper is based on this simplified receiving model.As a hotspot in array model research, the uniform linear array has the advantages of simplicity and practicality, and it is also the most common array model in practical applications, as shown in Figure1. We assume that there are M antennas in the space, uniformly distributed on a straight line, and the distance between each antenna is d. The order is from 1 to M, from left to right, and there are a large number of signal sources in the space. The target signal is introduced into the antenna array at the θ angle, and the mutual coupling effect between the antennas is ignored. Then, when the first antenna is the reference antenna, there is a delay τm when the target signal reaches the Mth antenna.(5)τm=m−1dsinθc=m−1τ.Figure 1
Uniform linear array model.Among them,d is the distance between the antennas, which is usually half the wavelength of the target signal, and c is the speed of light, which is the time delay between two consecutive antennas.The signal reception expression of the first antenna at timen is assumed to be the following:(6)xn=sn=unejw0f.Among them,w0 is the angular frequency of the target signal. By adding the narrowband signal of the target signal, the formula obtained is as follows:(7)xmn=snejw0m−1τ.The phaseφ at this time is as follows:(8)φ=w0τ=2πdsinθλ.Among them,λ is the wavelength of the target signal. It can be seen from the schematic diagram of the array antenna that when each antenna from 1 to M is selected, respectively, the formula obtained is as follows:(9)x1nx2n⋯xMn=1e−jφ⋯e−fM−1φsn.Then,x(n) and aθ are redefined as vectors in the above formula.(10)xn=x1nx2n⋯xMnT.The expression after the available target signal reaches the antenna array is as follows:(11)xn=aθsn.Among them,aθ and s(n) are the steering vector and the complex envelope of the target signal, respectively.The uniform linear array is a classic and commonly used one among all array models because of its simplicity and ease of implementation. However, there are also some flaws. Since all the antenna elements are arranged in a straight line, it also leads to a larger physical size of the model when the number of antennas is large, which may not be convenient for the development and integration of the entire system in actual engineering. Starting from its own characteristics, because it is a uniform linear array, it can only be used in a two-dimensional environment, i.e., it can only be used for linear distance and azimuth, and it is impossible to judge the depression angle and elevation angle.Based on the above-mentioned uniform lineararray model, this paperconducts a simulationanalysis on the waveforms of different array elements in the antenna system. It can be seen from Figure2 to Figure 5 of the simulation results that with the increase of the number of antenna elements, the number of side lobes also increases, the beam in the direction of the target signal becomes narrower, and the gain of the side lobes decreases continuously. It enables high-performance gain in the direction of the target signal, suppresses the direction of the interfering signal, and improves the gain performance of the entire antenna system for the direction of the target signal. The following simulation analysis in this paper is based on the uniform linear array antenna system with 8 elements.Figure 2
Directional diagram of a 4-element uniform linear array.Figure 3
Directional diagram of 8-element uniform linear array.Figure 4
Directional diagram of 16-element uniform linear array.Figure 5
Directional diagram of 32-element uniform linear array.Figure6 is a circular array model in which M antennas are arranged on a circle according to the same radian interval. It is assumed that the array antenna receives K signals with different directions and angles, and their parameter is θi,φi. Among them, θi is the depression angle, and θi is the azimuth angle, (i = 0,1,…, K−1). Usually, the distance between the antennas is half the wavelength of the target signal, and the radius of the uniform circular array can be obtained as follows:(12)R=λ/4sinπ/M.Figure 6
Uniform circular array model.Among them,λ is the wavelength of the target signal, and each antenna has a coordinate relationship with the X-axis, which is as follows:(13)γm=2πm−1M.Among them,m = o,1,…M-1. From this, the steering vector of the target signal can be obtained as follows:(14)aθi,φi=exp−j2πRsinθicosφi−γ0λexp−j2πRsinθicosφi−γ1λ⋯exp−j2πRsinθicosφi−γM−1λ.Compared with the uniform linear array model, the uniform circular array model has a great advantage in the spatial dimension. Since its angle covers the entire three-dimensional space, there is no blind spot with beams, and it can provide observation performance that uniform linear arrays do not have at depression angles. However, because of the omnidirectionality of the uniform circular array model, it has defects, such as large sidelobes.


### 3.2. Smart Antenna Technology

The principle of the adaptive beamforming technology is to use the training sequence and inherent characteristics of the signal in the entire data transmission and reception process to select an appropriate adaptive algorithm according to different decision criteria. Moreover, the weight vector on the antenna array element is adjusted by an algorithm to achieve the real-time dynamic adjustment of the beam in space, i.e., to achieve the purpose of retaining the target signal and removing the interference signal. The manifestation in space is a beam of directional waves. Moreover, the main lobes and nulls in the waveform can be used to align the desired direction and the interference direction, and the directions of the main lobe, side lobes, and nulls of the wave beam can be changed in real time.The output of the entire smart antenna system can be expressed as follows:(15)yt=∑i=1Mwixit.The weight of each antenna and the received signal can be represented by a vector.(16)wθ=w1θw2θ⋯wMθT,xt=x1tx2t⋯xMtT.Among them,m is the incident angle of the target signal. When the position of the target signal changes, the weight vector will also change. Each value in the weight vector is a complex number whose modulus and amplitude adjust the amplitude and phase of the received signal, respectively. Then, the output of the smart antenna system can be expressed as follows:(17)yt=wHθxt.It can be seen that when the smart antenna system generates the waveform, only the operations of addition and multiplication are used. When the distant target signal arrives at the antenna array, because of the different distances between the target signal and each antenna array element, the signal arrives at each array element with different time delays. Moreover, each antenna makes some phase adjustments to its own received signal, and the summation of the compensated data can achieve the same-phase superposition of the target signal, so that the target signal can obtain the directional gain of the antenna. The weight vector at this time is as follows:(18)wθ=1e−jwt⋯e−jM−1wtT.When only considering the beam in a certain direction, the direction vectoraθ in that direction is the same as that of the above weight vector. Hence, the output of the smart antenna system can be expressed as follows:(19)yt=wHθxt=aHθxt.


### 3.3. Evaluation Criteria for Beamforming Performance

The core point of beamforming technology in smart antennas is the weight vector corresponding to each antenna element. In the beamforming technology, the weight vector is adjusted in real time through suitable performance evaluation criteria and suitable algorithms, so that the main lobe and null of the beam in space are aligned with the target signal and the interference signal, respectively, and the purpose of spatial filtering is achieved. In this process, the selection of performance evaluation criteria and adaptive algorithm are particularly important. The choice will directly affect the response time of beam tracking in space, and the complexity and robustness of algorithms and criteria, and the feasibility of hardware structure implementation are all important factors for making the choice.When the mean square value of the error between the received signal and the expected signal reaches the minimum, it is considered that the system using the minimum mean square error criterion has reached the optimal state. This performance evaluation criterion only needs to use the difference between the target signal and the received signal to make the beamforming system reach the optimal state, which is common in practical applications.We assume that there is a uniform linear array model ofM antennas in the space, the received signal is xn=x1nx2n⋯xMnT, and the weight vector is w. Then, the output of the antenna system is yn=wHxn, an antenna array reference signal d(n) is assumed to be related to the target signal, and the error is defined as en=dn−yn=dn−wHxn.The mean square error refers to the squareen2 of the error between the expected signal and the output signal of the antenna array. Then, the statistical expectation E∗ is calculated, and the evaluation function is as follows:(20)Jw=Een2=Edn2−2wHrxd+wHRxxw.Among them,(21)Rxx=ExnxnH,rxd=Ednxn,∇wEen2=2Rxxw−2rxd.The weight vector expression calculated according to the minimum mean square error criterion can be obtained as follows:(22)wopt=Rxx−1rxd.The inversion of the full rankR in the minimum mean square error criterion can be solved by ordinary equations, however, the amount of calculation is large. However, the steepest descent method is a recursive algorithm that can solve this type of equation. It does not directly invert the matrix. It can start from a weight vector and iterate continuously in the direction of decreasing cost function value, and finally, it reaches an optimal solution. The advantage of this method is that the amount of calculation is small, and it is relatively simple to implement. The iterative expression of this method is given below.(23)wn+1=wn+μ−∇wEen2=wn+2μrxd−Rxxwn.The maximum signal-to-noise ratio criterion is the criterion to make the solution under certain constraints reach the maximum signal-to-noise ratio. The received signal is assumed to be the following:(24)xn=sn+nn.Among them,s(n) and n(n) are the received target signal and noise, respectively, and the output of the weighted summation of the antenna array weight vector can be obtained as follows:(25)yk=wHxn=wHsn=wHnn=ysn+ynn.Among them,(26)ysn=wHsn,ynn=wHnn.The ratio of the output signal power and noise power after the weighting of the antenna array can be obtained as follows:(27)Jw=SNR=Eytn2Eynn2=EwHsn2EwHnn2=wHRswwHRnw.After simplification and other processing, we can get the following:(28)Rn−1Rswopt=Jww.Among them,(29)Rx=EsksHkRn=EnnnHn,are the autocorrelation matrices of the received target signal and noise, respectively. Then, the cost function and weight vector are related to Rn−1Rs, which are the eigenvalues and eigenvectors of Rn−1Rs, respectively. Therefore, after decomposing the Rn−1Rs operation, it can be concluded that the maximum eigenvalue is the maximum signal-to-noise ratio in the system, and the corresponding eigenvector is the weight vector required in the system.(30)Rn−1Rswopt=λmaxwopt.The least squares criterion is the average over time after the squared sum of the errors. As with the minimum mean square error criterion, if the received signal isxn=x1nx2n…xMnT and the weight vector is w, then the output of the antenna array is yn=wHxn. We assume an antenna array reference signal d(n) relative to the target signal and define the error as follows: en=dn−yn=dn−wHxn .Then, we assume the following:(31)Xn=x1x2⋯xn,Dn=d1d2⋯dn.We get the following:(32)en=Dn−wHXn.Then, the cost function is as follows:(33)Jw=∑i=1nλn+1ei2=Dn−wHXnΛnDn−wHXnH.Among them,λ0<λ<1 is called the forgetting factor, which can reduce the proportion of data from a long time ago in the current system to have a small impact on the performance of the current system. Among them, there are diagonal matrices as follows:(34)Λn=Diagλn−1λn−3⋯1.Then, the cost function is differentiated and made equal to 0.(35)∇Jwn=0.The solution of the final weight vector can be obtained as follows:(36)wopt=XnΛnXHn−1XnΛnDHn.Likewise, if the received signal isxn=x1nx2n⋯xMnT and the weight vector is w. Then, the output of the antenna array is yn=wHxn. Furthermore, we assume an antenna array reference signal d(n) relative to the target signal and define the error as en=dn−yn=dn−wHxn. The evaluation function is as follows:(37)Jw=Eyn2=wHRxxw.Among them,(38)Rxx=ExnxnH,is the covariance matrix of the received signal x(n).The linear constraint minimum variance criterion is to minimize the output variance of the antenna array after weighingby the weight vector without changing the expected signal power and certain constraints. It can be understood as filtering out the noise in the signal. A common constraint method is to make the following:(39)wHd=c.Among them,c is a constant.The Lagrangian expression can be constructed before solving the weight vector.(40)Lw=wHRxxw+λwHs−1.By taking the derivative of the above formula and setting its result equal to 0, we get the following:(41)wopt=R−1ssHR−1s−1.The input signal of the array antenna is assumed to be the following:(42)xn=sn+nn.Among them,s(n) and n(n) are the received target signal and noise, respectively.Under the given precondition ofs(n), the probability expression of the occurrence of the received signal x(n) of the antenna array can be obtained as follows:(43)Pxn|sn.Alternatively, the probability expression is taken logarithmically.(44)lnPxn|sn.This probability expression in logarithmic form is the evaluation function in the maximum likelihood criterion.(45)Jw=lnPxn|sn.At the same time, we assume thatn is a Gaussian noise with mean 0, and the evaluation function at this time is as follows:(46)Jw=αxn−snsHRnn−1xn−sns.Among them,Rnn and α are the autocorrelation matrix of the Gaussian noise and a constant, respectively, and then the estimated expression for the desired signal s(n) is as follows:(47)s^n=yn=wHxn.Similarly, to find the weight vectorw that minimizes the evaluation function J(w), we take the derivative of the evaluation function and make its reciprocal equal to 0.(48)∇Jw=−2sHRnn−1xn=2s^nsHRnn−1s=0.The weight vectorw under the maximum likelihood criterion can be obtained as follows:(49)wopt=Rnn−1ssHRnn−1s.


## 3.1. Antenna Model

In the array antenna technology, we assume that a signal has a bandwidth ofWB and a center frequency of f0. If the ratio of bandwidth to center frequency is much less than 1,(1)WBf0≪1.Then, the signal is a narrowband signal.The expression after the signalst, whose center frequency is f0, reaches the antenna array is as follows:(2)st=utej2πf0t+vt.Among them,ut is the amplitude modulation function, and vt is the phase modulation function. At the same time, the influence of delay also needs to be considered in the array antenna technology, and the delay of the target signal is assumed to be r.(3)st−τ=ut−τej2πf0t−τ+vt−τ.If the target signalst is a narrowband signal, then ut and vt change less with time, and when z is small, it can become the following:(4)st−τ≈ste−j2πf0t.To sum up, for narrowband signals, the small delay has little effect on the amplitude, and it only produces some phase changes. The research in this paper is based on this simplified receiving model.As a hotspot in array model research, the uniform linear array has the advantages of simplicity and practicality, and it is also the most common array model in practical applications, as shown in Figure1. We assume that there are M antennas in the space, uniformly distributed on a straight line, and the distance between each antenna is d. The order is from 1 to M, from left to right, and there are a large number of signal sources in the space. The target signal is introduced into the antenna array at the θ angle, and the mutual coupling effect between the antennas is ignored. Then, when the first antenna is the reference antenna, there is a delay τm when the target signal reaches the Mth antenna.(5)τm=m−1dsinθc=m−1τ.Figure 1
Uniform linear array model.Among them,d is the distance between the antennas, which is usually half the wavelength of the target signal, and c is the speed of light, which is the time delay between two consecutive antennas.The signal reception expression of the first antenna at timen is assumed to be the following:(6)xn=sn=unejw0f.Among them,w0 is the angular frequency of the target signal. By adding the narrowband signal of the target signal, the formula obtained is as follows:(7)xmn=snejw0m−1τ.The phaseφ at this time is as follows:(8)φ=w0τ=2πdsinθλ.Among them,λ is the wavelength of the target signal. It can be seen from the schematic diagram of the array antenna that when each antenna from 1 to M is selected, respectively, the formula obtained is as follows:(9)x1nx2n⋯xMn=1e−jφ⋯e−fM−1φsn.Then,x(n) and aθ are redefined as vectors in the above formula.(10)xn=x1nx2n⋯xMnT.The expression after the available target signal reaches the antenna array is as follows:(11)xn=aθsn.Among them,aθ and s(n) are the steering vector and the complex envelope of the target signal, respectively.The uniform linear array is a classic and commonly used one among all array models because of its simplicity and ease of implementation. However, there are also some flaws. Since all the antenna elements are arranged in a straight line, it also leads to a larger physical size of the model when the number of antennas is large, which may not be convenient for the development and integration of the entire system in actual engineering. Starting from its own characteristics, because it is a uniform linear array, it can only be used in a two-dimensional environment, i.e., it can only be used for linear distance and azimuth, and it is impossible to judge the depression angle and elevation angle.Based on the above-mentioned uniform lineararray model, this paperconducts a simulationanalysis on the waveforms of different array elements in the antenna system. It can be seen from Figure2 to Figure 5 of the simulation results that with the increase of the number of antenna elements, the number of side lobes also increases, the beam in the direction of the target signal becomes narrower, and the gain of the side lobes decreases continuously. It enables high-performance gain in the direction of the target signal, suppresses the direction of the interfering signal, and improves the gain performance of the entire antenna system for the direction of the target signal. The following simulation analysis in this paper is based on the uniform linear array antenna system with 8 elements.Figure 2
Directional diagram of a 4-element uniform linear array.Figure 3
Directional diagram of 8-element uniform linear array.Figure 4
Directional diagram of 16-element uniform linear array.Figure 5
Directional diagram of 32-element uniform linear array.Figure6 is a circular array model in which M antennas are arranged on a circle according to the same radian interval. It is assumed that the array antenna receives K signals with different directions and angles, and their parameter is θi,φi. Among them, θi is the depression angle, and θi is the azimuth angle, (i = 0,1,…, K−1). Usually, the distance between the antennas is half the wavelength of the target signal, and the radius of the uniform circular array can be obtained as follows:(12)R=λ/4sinπ/M.Figure 6
Uniform circular array model.Among them,λ is the wavelength of the target signal, and each antenna has a coordinate relationship with the X-axis, which is as follows:(13)γm=2πm−1M.Among them,m = o,1,…M-1. From this, the steering vector of the target signal can be obtained as follows:(14)aθi,φi=exp−j2πRsinθicosφi−γ0λexp−j2πRsinθicosφi−γ1λ⋯exp−j2πRsinθicosφi−γM−1λ.Compared with the uniform linear array model, the uniform circular array model has a great advantage in the spatial dimension. Since its angle covers the entire three-dimensional space, there is no blind spot with beams, and it can provide observation performance that uniform linear arrays do not have at depression angles. However, because of the omnidirectionality of the uniform circular array model, it has defects, such as large sidelobes.


## 3.2. Smart Antenna Technology

The principle of the adaptive beamforming technology is to use the training sequence and inherent characteristics of the signal in the entire data transmission and reception process to select an appropriate adaptive algorithm according to different decision criteria. Moreover, the weight vector on the antenna array element is adjusted by an algorithm to achieve the real-time dynamic adjustment of the beam in space, i.e., to achieve the purpose of retaining the target signal and removing the interference signal. The manifestation in space is a beam of directional waves. Moreover, the main lobes and nulls in the waveform can be used to align the desired direction and the interference direction, and the directions of the main lobe, side lobes, and nulls of the wave beam can be changed in real time.The output of the entire smart antenna system can be expressed as follows:(15)yt=∑i=1Mwixit.The weight of each antenna and the received signal can be represented by a vector.(16)wθ=w1θw2θ⋯wMθT,xt=x1tx2t⋯xMtT.Among them,m is the incident angle of the target signal. When the position of the target signal changes, the weight vector will also change. Each value in the weight vector is a complex number whose modulus and amplitude adjust the amplitude and phase of the received signal, respectively. Then, the output of the smart antenna system can be expressed as follows:(17)yt=wHθxt.It can be seen that when the smart antenna system generates the waveform, only the operations of addition and multiplication are used. When the distant target signal arrives at the antenna array, because of the different distances between the target signal and each antenna array element, the signal arrives at each array element with different time delays. Moreover, each antenna makes some phase adjustments to its own received signal, and the summation of the compensated data can achieve the same-phase superposition of the target signal, so that the target signal can obtain the directional gain of the antenna. The weight vector at this time is as follows:(18)wθ=1e−jwt⋯e−jM−1wtT.When only considering the beam in a certain direction, the direction vectoraθ in that direction is the same as that of the above weight vector. Hence, the output of the smart antenna system can be expressed as follows:(19)yt=wHθxt=aHθxt.


## 3.3. Evaluation Criteria for Beamforming Performance

The core point of beamforming technology in smart antennas is the weight vector corresponding to each antenna element. In the beamforming technology, the weight vector is adjusted in real time through suitable performance evaluation criteria and suitable algorithms, so that the main lobe and null of the beam in space are aligned with the target signal and the interference signal, respectively, and the purpose of spatial filtering is achieved. In this process, the selection of performance evaluation criteria and adaptive algorithm are particularly important. The choice will directly affect the response time of beam tracking in space, and the complexity and robustness of algorithms and criteria, and the feasibility of hardware structure implementation are all important factors for making the choice.When the mean square value of the error between the received signal and the expected signal reaches the minimum, it is considered that the system using the minimum mean square error criterion has reached the optimal state. This performance evaluation criterion only needs to use the difference between the target signal and the received signal to make the beamforming system reach the optimal state, which is common in practical applications.We assume that there is a uniform linear array model ofM antennas in the space, the received signal is xn=x1nx2n⋯xMnT, and the weight vector is w. Then, the output of the antenna system is yn=wHxn, an antenna array reference signal d(n) is assumed to be related to the target signal, and the error is defined as en=dn−yn=dn−wHxn.The mean square error refers to the squareen2 of the error between the expected signal and the output signal of the antenna array. Then, the statistical expectation E∗ is calculated, and the evaluation function is as follows:(20)Jw=Een2=Edn2−2wHrxd+wHRxxw.Among them,(21)Rxx=ExnxnH,rxd=Ednxn,∇wEen2=2Rxxw−2rxd.The weight vector expression calculated according to the minimum mean square error criterion can be obtained as follows:(22)wopt=Rxx−1rxd.The inversion of the full rankR in the minimum mean square error criterion can be solved by ordinary equations, however, the amount of calculation is large. However, the steepest descent method is a recursive algorithm that can solve this type of equation. It does not directly invert the matrix. It can start from a weight vector and iterate continuously in the direction of decreasing cost function value, and finally, it reaches an optimal solution. The advantage of this method is that the amount of calculation is small, and it is relatively simple to implement. The iterative expression of this method is given below.(23)wn+1=wn+μ−∇wEen2=wn+2μrxd−Rxxwn.The maximum signal-to-noise ratio criterion is the criterion to make the solution under certain constraints reach the maximum signal-to-noise ratio. The received signal is assumed to be the following:(24)xn=sn+nn.Among them,s(n) and n(n) are the received target signal and noise, respectively, and the output of the weighted summation of the antenna array weight vector can be obtained as follows:(25)yk=wHxn=wHsn=wHnn=ysn+ynn.Among them,(26)ysn=wHsn,ynn=wHnn.The ratio of the output signal power and noise power after the weighting of the antenna array can be obtained as follows:(27)Jw=SNR=Eytn2Eynn2=EwHsn2EwHnn2=wHRswwHRnw.After simplification and other processing, we can get the following:(28)Rn−1Rswopt=Jww.Among them,(29)Rx=EsksHkRn=EnnnHn,are the autocorrelation matrices of the received target signal and noise, respectively. Then, the cost function and weight vector are related to Rn−1Rs, which are the eigenvalues and eigenvectors of Rn−1Rs, respectively. Therefore, after decomposing the Rn−1Rs operation, it can be concluded that the maximum eigenvalue is the maximum signal-to-noise ratio in the system, and the corresponding eigenvector is the weight vector required in the system.(30)Rn−1Rswopt=λmaxwopt.The least squares criterion is the average over time after the squared sum of the errors. As with the minimum mean square error criterion, if the received signal isxn=x1nx2n…xMnT and the weight vector is w, then the output of the antenna array is yn=wHxn. We assume an antenna array reference signal d(n) relative to the target signal and define the error as follows: en=dn−yn=dn−wHxn .Then, we assume the following:(31)Xn=x1x2⋯xn,Dn=d1d2⋯dn.We get the following:(32)en=Dn−wHXn.Then, the cost function is as follows:(33)Jw=∑i=1nλn+1ei2=Dn−wHXnΛnDn−wHXnH.Among them,λ0<λ<1 is called the forgetting factor, which can reduce the proportion of data from a long time ago in the current system to have a small impact on the performance of the current system. Among them, there are diagonal matrices as follows:(34)Λn=Diagλn−1λn−3⋯1.Then, the cost function is differentiated and made equal to 0.(35)∇Jwn=0.The solution of the final weight vector can be obtained as follows:(36)wopt=XnΛnXHn−1XnΛnDHn.Likewise, if the received signal isxn=x1nx2n⋯xMnT and the weight vector is w. Then, the output of the antenna array is yn=wHxn. Furthermore, we assume an antenna array reference signal d(n) relative to the target signal and define the error as en=dn−yn=dn−wHxn. The evaluation function is as follows:(37)Jw=Eyn2=wHRxxw.Among them,(38)Rxx=ExnxnH,is the covariance matrix of the received signal x(n).The linear constraint minimum variance criterion is to minimize the output variance of the antenna array after weighingby the weight vector without changing the expected signal power and certain constraints. It can be understood as filtering out the noise in the signal. A common constraint method is to make the following:(39)wHd=c.Among them,c is a constant.The Lagrangian expression can be constructed before solving the weight vector.(40)Lw=wHRxxw+λwHs−1.By taking the derivative of the above formula and setting its result equal to 0, we get the following:(41)wopt=R−1ssHR−1s−1.The input signal of the array antenna is assumed to be the following:(42)xn=sn+nn.Among them,s(n) and n(n) are the received target signal and noise, respectively.Under the given precondition ofs(n), the probability expression of the occurrence of the received signal x(n) of the antenna array can be obtained as follows:(43)Pxn|sn.Alternatively, the probability expression is taken logarithmically.(44)lnPxn|sn.This probability expression in logarithmic form is the evaluation function in the maximum likelihood criterion.(45)Jw=lnPxn|sn.At the same time, we assume thatn is a Gaussian noise with mean 0, and the evaluation function at this time is as follows:(46)Jw=αxn−snsHRnn−1xn−sns.Among them,Rnn and α are the autocorrelation matrix of the Gaussian noise and a constant, respectively, and then the estimated expression for the desired signal s(n) is as follows:(47)s^n=yn=wHxn.Similarly, to find the weight vectorw that minimizes the evaluation function J(w), we take the derivative of the evaluation function and make its reciprocal equal to 0.(48)∇Jw=−2sHRnn−1xn=2s^nsHRnn−1s=0.The weight vectorw under the maximum likelihood criterion can be obtained as follows:(49)wopt=Rnn−1ssHRnn−1s.


## 4. Music Genre Classification Algorithm Based on Multihead Attention Mechanism

The system in this paper is based on the end-to-end speech recognition model structure of LAS. The system structure consists of three modules: encoding network, decoding network, and attention network, as shown in Figure7.Figure 7
End-to-end model structure based on multihead attention mechanism.A song is composed of many clips. In addition to the rhythm features of the whole song, a total of 17-dimensional features are extracted from each Clip. How to determine the genre of a song from the genres of all Clips of a song is related to how to define the similarity between songs. In music genre classification, many scholars have tried many classification strategies, such as neural network,K-nearest neighbor, Gaussian mixture model, etc. Since neural networks, especially multilayer perceptrons (MLP), are relatively successful in music classification applications, this paper adopts the MLP model to achieve the automatic division of music genres, as shown in Figure 8.Figure 8
Music genre classification based on multihead attention mechanism.On the basis of the above research, the experimental study of the music genre classification algorithm based on the multihead attention mechanism proposed in this paper is carried out.Obtain different types of music audios through multiple platforms, classify these music genres according to the labels of music genres, and randomly combine these audios in a random grouping manner. Each group contains 10,000 audios, and a total of 30 experimental groups are set up.In this paper, the classification effect of the model in this paper is counted, and the model proposed in this paper is compared with literature [9], and the results shown in Table 1 and Figure 9 are obtained. The experimental results in the table show the accuracy of the model for music genre classification.Table 1
Music genre classification effect of the music genre classification algorithm based on the multihead attention mechanism.
NumThe method of this paperThe method of [9]188.3480.37284.6275.31387.0982.63484.6273.28589.4179.02684.5471.97792.5379.27889.8879.02988.6680.061092.6787.421185.4879.441291.1586.131385.3178.041484.7672.171585.8679.251689.2879.601787.1279.711887.5076.321986.6981.492085.0978.542187.5074.522292.3782.942390.0380.492484.9072.382584.0975.872686.9776.312785.0078.842892.8285.052992.7187.033086.4975.92Figure 9
Comparison diagram of music genre classification effects of music genre classification algorithm based on multihead attention mechanism.From the above research, it can be seen that the music genre classification algorithm based on the multihead attention mechanism proposed in this paper has obvious advantages over traditional algorithms, and it has a certain role in music genre classification.


## 5. Conclusion

Music genre automatic classification method is a research hotspot in the field of current music information acquisition. How to automatically determine the category of a piece of music can reduce labor costs and ensure the accuracy of the judgment. Although the current popular K-nearest neighbors, Gaussian mixture models, and support vector machine models can achieve acceptable results, the planar structure classification method cannot fully display the relative distance and hierarchical relationship between different schools. This paper combines the multihead attention mechanism to study the music genre classification algorithm model to improve the music genre classification effect. It can be seen from the experimental research that the music genre classification algorithm based on the multihead attention mechanism proposed in this paper has obvious advantages compared with the traditional algorithm, and it has a certain role in music genre classification.The swarm intelligence algorithm used in this paper is the classic state after the algorithm was proposed. At present, many scholars have improved and optimized the swarm intelligence algorithm. There may be some optimization methods that will make the improved adaptive algorithm based on the swarm intelligence algorithm. The convergence performance is better. Also, combining the improved swarm intelligence algorithm into the adaptive algorithm can be a future research direction.



---

*Source: 3845390-2022-08-09.xml*