# Prediction of Cotton Yarn Quality Based on Attention-GRU
## 1 Introduction
Specifically, the relative average error for predicting yarn tensile strength was reduced by 2.1%. [PERSON] et al. [12; 13] optimized the weight and threshold of the BP neural network using bio-inspired algorithms, such as genetic algorithms and fireworks algorithms, thereby enhancing the optimization speed and accuracy of the yarn quality prediction model. In summary, leveraging the potential of deep learning theory, particularly the BP neural network, presents a promising avenue for refining the prediction of yarn quality, catering to the intricacies of spinning processes and contributing to enhanced production outcomes. However, the spinning process involves a time-series task scenario characterized by interconnected pre-processing and post-processing stages [14; 15]. Most prediction models based on BP neural networks primarily utilize physical indicators of raw cotton as input parameters and analyze the production parameters of cotton yarn only at the same time point. They rarely involve the input of process parameters from different preceding and subsequent stages of production. Even if such consideration is made, the temporal influence of processing stages on yarn quality is often overlooked. Consequently, these models fail to establish connections among the temporal characteristics of various spinning workshop production stages, leading to an inability to meet the accuracy requirements of actual quality inspections for yarn spinning. As a network sensitive to time sequences, the LSTM neural network has found widespread application in scenarios involving sequential data. [PERSON] [16] optimized the input feature parameters of the LSTM neural network through the use of the convolutional neural networks (CNN) algorithm. Furthermore, they fine-tuned cotton fiber performance indicators and production parameters based on the sequence of yarn processing. This approach led to predictions of quality metrics, such as yarn strength and total cotton content. The average absolute error of their model's predictive results was recorded as 0.080, which was lower than comparative models, such as the BP neural network. However, the complexity of their network structure inadvertently compromised the overall operational efficiency of yarn quality prediction. In conclusion, this study addresses the challenges in cotton-spinning production related to raw cotton properties, process parameters, and yarn quality data. By integrating actual production process requirements from workshops and employing an attention mechanism-improved GRU neural network, we establish a cotton yarn quality prediction model that accounts for processing temporalities. This approach aims to enhance the accuracy of prediction results, which may otherwise suffer due to the sequential nature of spinning processes and production procedures. Ultimately, this model assists production personnel in efficiently determining cotton-blending strategies and processing parameters, thereby contributing to improved enterprise production efficiency. The primary contributions of this study are outlined as follows:  
1. A cotton yarn quality prediction model based on attention-GRU was devised. This model incorporates an attention mechanism that directs the model's focus towards the most significant input features influencing yarn quality. Additionally, a dynamic adaptation of the loss change threshold has been introduced to determine the optimal number of iterations for different datasets. This approach not only enhances the precision of model predictions but also boosts prediction efficiency. 2. A research dataset was constructed incorporating raw cotton performance indicators and data from the regular carding process. By organizing raw cotton performance indicators and processing information from the spinning workshop, a driving dataset was established for the model, aligning it more closely with practical scenarios in cotton yarn spinning. 3.