Skip to main content
. 2024 Feb 22;24(5):1429. doi: 10.3390/s24051429
Algorithm 1. The pseudocode of the model.
Input: Time-frequency characteristics X1,X2,…,XT
Output: Emotion categories and probabilities Y, P
// Bi-GRU algorithm (forward and backward)
ht→←GRU→xt,ht−1
ht↼→GRU↼xt,h˜t−1
ht=[ht→,ht↼]
// Multi-head Attention algorithm
Q=ht⋅Wq, K=ht⋅Wk, V=ht⋅Wv
AttentionScorei=softmaxQWQiTKTdk
headi=AttentionScorei⋅V
MultiHeadQ,K,V=Concathead1,…,headhWO
// Linear layer and output layer
Y′=full connectMultiHeadQ,K,V
Y=softmax(Y′)