A deep learning-based intelligent pattern recognition method for poultry health status

CN123016335APending Publication Date: 2026-10-30SICHUAN HONGSHENG AGRI DEV CO LTD +1
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611146091.9
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-30
Publication Date
2026-10-30

AI Technical Summary

Technical Problem

[0006]本发明的目的在于提供一种基于深度学习的家禽健康状态智能化模式识别方法,以解决现有技术中加权损失函数缺乏类别层面动态感知、群体智能优化算法个体目标同质化、以及超参数寻优缺乏分阶段递进机制的技术问题,最终提升了家禽健康状态智能识别准确率

Benefits of technology

[0062]首先,本发明提出的基于类别感知的动态加权损失函数(Class-Aware DynamicWeighted Loss,CADWL),通过计算各类别当前批次的平均损失,从类别整体层面感知各类别的学习难度,克服了现有方法仅依赖单个样本置信度的缺陷;同时将损失感知与频率感知自适应融合,并采用指数移动平均进行平滑处理,保证了加权系数的稳定演化,融合系数随训练进度自适应调整,实现了训练阶段优化重点的平滑迁移。其次,本发明提出的基于类别感知的精英协同搜索算法(Class-Aware Elite Collaborative Search,CEACS),通过异质化精英种群设计,使每个精英个体专属负责一个类别,克服了传统群体智能算法所有个体共享同一适应度函数导致部分类别性能被牺牲的缺陷;采用基于历史梯度估计的专属驱动力与基于距离和适应度加权的协作驱动力相结合的双驱动力更新机制,并在迭代过程中动态调整两种驱动力的权重,实现了探索与利用的有效平衡。最后,本发明采用两阶段递进寻优策略,第一阶段以较少训练轮次快速筛选候选参数,第二阶段以较多训练轮次精确评估最优参数,在保证优化精度的同时大幅降低了计算成本。本发明将类别感知动态加权损失函数与精英协同搜索算法有机融合,显著提升了家禽健康状态识别的准确率,具有参数自适应性好、计算效率高、识别结果可靠等优点,可广泛应用于智能化养殖场景下的家禽健康状态自动监测。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN123016335A_ABST
    Figure CN123016335A_ABST
Patent Text Reader

Abstract

The application discloses a kind of poultry health state intelligent mode identification method based on deep learning, belong to deep learning and pattern recognition technical field.It includes: obtaining poultry feces image dataset and health state label;Baseline deep learning model for poultry health state recognition based on visual Transformer is constructed;Dynamic weighted loss function is constructed, and the weighting coefficient of each category is determined by dynamic fusion of average loss and category frequency distribution;The hyperparameters in dynamic weighted loss function are optimized in two stages using swarm intelligence algorithm, to obtain the optimal hyperparameter combination;The baseline deep learning model is trained based on the optimal hyperparameter combination, to obtain the target deep learning model;The target deep learning model is used to identify poultry feces image, and output health state.The application improves the accuracy of poultry health state intelligent identification, and is suitable for poultry health state automatic monitoring in intelligent breeding scene.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of deep learning and pattern recognition technology, and more specifically, to an intelligent pattern recognition method for poultry health status based on deep learning. Background Technology

[0002] Poultry farming is a crucial component of agricultural production, and accurate identification of poultry health status is essential for disease prevention and control, minimizing economic losses, and ensuring food safety. In recent years, deep learning technology, especially Vision Transformer (ViT), has made significant progress in image recognition, providing new technical approaches for poultry health status identification. However, practical applications still face the following key challenges:

[0003] On the one hand, existing weighted loss functions either calculate weights based solely on the prediction confidence of a single sample, failing to perceive the learning difficulty of each category at the overall category level, resulting in inconsistent weights within the same category; or they rely solely on the number of samples, failing to reflect the dynamic changes of each category during training. Furthermore, the fusion coefficients of loss-aware and frequency-aware methods largely depend on manual experience and lack adaptive adjustment capabilities.

[0004] On the other hand, existing swarm intelligence optimization algorithms share the same fitness function among all individuals, which can easily come at the cost of sacrificing the performance of some classes. At the same time, the cooperation mechanism of existing algorithms relies only on global or individual optima for position updates, lacking the use of search history information, resulting in slow convergence and low efficiency in large-scale hyperparameter spaces. Finally, existing methods only perform a single complete training evaluation, with each evaluation involving huge computational costs. They lack a phased strategy of "coarse screening first, then fine tuning," leading to low efficiency in hyperparameter search and difficulty in obtaining the optimal configuration under limited computing resources.

[0005] In summary, existing technologies urgently need a method for identifying poultry health status that can dynamically perceive the learning difficulty of each category at the category level, adaptively fuse multi-dimensional weighted signals, and achieve efficient and automatic optimization of hyperparameters. Summary of the Invention

[0006] The purpose of this invention is to provide an intelligent pattern recognition method for poultry health status based on deep learning, in order to solve the technical problems in the prior art, such as the lack of dynamic perception at the category level in the weighted loss function, the homogenization of individual targets in the swarm intelligence optimization algorithm, and the lack of a phased progressive mechanism in hyperparameter optimization, and ultimately improve the accuracy of intelligent recognition of poultry health status.

[0007] This invention is implemented as follows:

[0008] The technical solution for achieving the objective of this invention is: an intelligent pattern recognition method for poultry health status based on deep learning, characterized by comprising the following steps:

[0009] Step S1: Obtain poultry feces image dataset and health status labels;

[0010] Step S2: Construct a baseline deep learning model for poultry health status recognition based on visual Transformer;

[0011] Step S3: Construct a dynamic weighted loss function; in the dynamic weighted loss function, the weighting coefficients of each category are dynamically determined by the weighted fusion result of the average loss of the current batch of that category and the category frequency distribution, and are smoothed by exponential moving average;

[0012] Step S4: The swarm intelligence optimization algorithm is used to perform two-stage optimization of the hyperparameters in the dynamic weighted loss function to obtain the optimal hyperparameter combination. The swarm intelligence optimization algorithm contains N elite individuals, each elite individual corresponds to a category, and the F1 score corresponding to the category is used as the individual's exclusive fitness function. Each elite individual updates its position through historical gradient estimation and group cooperation information to realize parallel search and collaborative optimization of hyperparameters.

[0013] Step S5: Based on the optimal hyperparameter combination, train the baseline deep learning model using the dynamic weighted loss function to obtain the target deep learning model;

[0014] Step S6: Input the poultry feces image to be identified into the target deep learning model and output the health status identification result.

[0015] Furthermore, in step S3, the weighted loss function is a category-aware dynamic weighted loss function, which determines the weighting coefficients for each category through the following steps:

[0016] Step S31: Obtain the number N of samples in each category in the current training batch. c ;

[0017] Step S32: Calculate the average cross-entropy loss l for each category in the current batch. c ;

[0018] l c =1 / B c ×Σ i:yi =c (-log(p(y i |x i )))

[0019] Where i is the sample number in the current batch, x i For the first i samples, y i Let B be the true class label of the i-th sample. c p(y) represents the number of samples of category c in the current batch. i |x i ) represents the model for sample x i Predicted as true label y i The probability of;

[0020] Step S33: Based on the average loss of each category c Loss perception weights are calculated using temperature scaling:

[0021] w c loss =exp(l c / τ) / (Σ j=1:C (exp(l j / τ)))×C

[0022] Among them, w c loss Let τ be the loss perception weight for category c, where C is the total number of categories and τ is the temperature coefficient.

[0023] Step S34: Based on the number of samples N for each category c Calculate the frequency-aware weight w c freq :

[0024] w c freq =1 / N c / (Σ j=1:C (1 / N j ))×C

[0025] Step S35: Adaptively fuse the loss-aware weights and frequency-aware weights to obtain the initial weighting coefficients W for each category. c,ini and to W c,ini After normalization, the final weighted coefficients W for each category are obtained. c :

[0026] W c,ini =α×w c loss +(1-α)×w c freq

[0027] W c = W c,ini / Σ j=1:C (W c,ini )×C

[0028] Where α is the balance coefficient, used to control the fusion ratio of loss perception and frequency perception;

[0029] Step S36: Smooth the weighting coefficients of each category using an exponential moving average to obtain the final smoothed weighting coefficients for each category:

[0030] O c (t)=β×O c (t-1)+(1-β)×W c (t)

[0031] Among them, O c (t) and O c (t-1) represents the final smoothing weighting coefficient of category c in the t-th and t-1-th iterations, β is the momentum coefficient, and W c (t) represents the weighting coefficient for the t-th iteration.

[0032] Step S37: Use the final smoothing weighting coefficients to weight the standard cross-entropy loss function to obtain a category-aware dynamic weighted loss function:

[0033] L CADWL =1 / B×Σ i=1:B (O yi ×-log(p(y i |x i )))

[0034] Where B is the batch size, and O yi The sample x obtained in step S36 i Category y i The smoothing weighting coefficients.

[0035] Furthermore, in step S35, the balance coefficient α is adaptively adjusted according to the training progress:

[0036] α(e) = α0 × (1 - 0.3e / T)

[0037] Where α0 is the initial balance coefficient, e is the current training round, and T is the preset maximum training round; that is, in the early stage of training, frequency-aware weights are more relied upon to focus on the minority class, while in the later stage of training, loss-aware weights are more relied upon for fine-tuning.

[0038] Furthermore, in step S4, the swarm intelligence optimization algorithm is a category-aware elite collaborative search algorithm, specifically including the following steps:

[0039] Step S41: Initialize a heterogeneous elite population: Randomly generate N elite individuals within the hyperparameter search space. The number of elite individuals N is equal to the number of classes in the dataset, and each elite individual i uniquely corresponds to a class c. i and with the F1 score F of that category ci(θ) serves as the individual's fitness function.

[0040] Step S42: Perform an initial evaluation of the objective function for each elite individual and record the initial position θ of each elite individual. i (0) and the initial fitness value, and store them in the evaluation history of the elite;

[0041] Step S43: Parallel Search Update: Each elite individual i updates its position according to its own fitness function and group cooperation information, following the dual-drive position update formula:

[0042] θ i (t+1)= θ i (t)+ η(t)×▽F ci h (θ i (t))+ κ(t)×Σ j≠i ω ij ×(θ j (t)- θ i (t))

[0043] Where, θ i (t) represents the position of the i-th elite individual in the t-th iteration, ▽F ci h (θ i (t) represents the gradient direction of the fitness function estimated based on historical evaluation data, fitted using local linear regression; η(t) is the individual driving force coefficient, κ(t) is the cooperative driving force coefficient, and ω ij Let J be the collaboration weight between elite individual j and elite individual i.

[0044] The cooperation weight ω ij The fitness value F of elite individual j in the current iteration cj And its distance from individual i in the search space together determine:

[0045] ω ij =exp(-d ij 2 / 2σ 2 )×F cj / (Σ k≠i exp(-d ik 2 / 2σ 2 )×F ck )

[0046] Where, d ij Let d be the Euclidean distance between individual i and individual j in the search space. ik Let σ be the Euclidean distance between individual i and elite individual k in the search space, σ be the distance scale parameter, and ω be the collaboration weight.ij Satisfy Σ j≠i ω ij =1;F ck This represents the fitness value of the k-th elite individual in the current iteration.

[0047] Step S44: Evaluate the objective function for the updated elite individuals, and update the position, fitness value and evaluation history of each elite individual;

[0048] Step S45: Repeat steps S43 to S44 until the preset number of iterations is reached. Each elite individual outputs the hyperparameter combination that maximizes the F1 score of its responsible category. After summarizing and removing duplicates, a candidate parameter set is formed.

[0049] Furthermore, in step S43, the dedicated driving force coefficient η(t) and the cooperative driving force coefficient κ(t) are adaptively adjusted as the iteration progresses:

[0050] η(t) = η0 × (1 - t / T) max )

[0051] κ(t) = κ0 × t / T max

[0052] Where t is the current iteration number, T max To preset the maximum number of iterations, η0 and κ0 are the initial exclusive driving force coefficient and the initial collaborative driving force coefficient, respectively. That is, in the early stage of optimization, exclusive driving force is the main factor, and each elite individual independently explores the optimal region of its own category; in the later stage of optimization, collaborative driving force is the main factor, and each elite individual influences each other to promote the synergistic integration of candidate parameters.

[0053] Furthermore, in step S4, the two-stage optimization specifically includes:

[0054] Phase 1: The swarm intelligence optimization algorithm described in step S4 is used to search for hyperparameters. The F1 score of each elite individual in the category they are responsible for is used as the exclusive fitness function. The model training and evaluation of each candidate hyperparameter combination is carried out for a preset number of rounds to generate a candidate parameter set S.

[0055] The second stage: With the overall accuracy as the optimization objective, the model training evaluation of each candidate hyperparameter combination is carried out on the candidate parameter set S for a preset second round, and the hyperparameter combination that achieves the highest overall accuracy is selected as the final optimal parameter.

[0056] The number of preset first rounds is less than the number of preset second rounds.

[0057] Furthermore, in step S43, the method for estimating the gradient direction of the fitness function based on historical evaluation data is as follows:

[0058] Select the position θ from the evaluation history. i (t) The K most recent historical points are used to construct a local linear model:

[0059] f(θ)≈▽F ci h ·θ+b

[0060] Among them, ▽F ci h The gradient direction of the fitness function is estimated, and b is the bias term. The coefficients of the local linear model are solved by the least squares method, and the slope vector is taken as the estimated value of the gradient direction. When the K historical points are collinear or insufficient, the estimated value of the gradient direction is set to the zero vector.

[0061] The beneficial effects of this invention are:

[0062] First, the proposed Class-Aware Dynamic Weighted Loss (CADWL) function in this invention calculates the average loss of each class in the current batch, perceiving the learning difficulty of each class from the overall class level, overcoming the deficiency of existing methods that rely solely on the confidence of a single sample. Simultaneously, it adaptively fuses loss perception and frequency perception, employing exponential moving average for smoothing, ensuring the stable evolution of the weighting coefficients. The fusion coefficients are adaptively adjusted with the training progress, achieving a smooth shift in optimization focus during the training phase. Second, the proposed Class-Aware Elite Collaborative Search (CEACS) algorithm in this invention, through a heterogeneous elite population design, ensures that each elite individual is exclusively responsible for a class, overcoming the deficiency of traditional swarm intelligence algorithms where all individuals share the same fitness function, leading to the sacrifice of performance in some classes. It employs a dual-drive update mechanism combining an exclusive driving force based on historical gradient estimation and a collaborative driving force based on distance and fitness weighting, dynamically adjusting the weights of the two driving forces during iteration, achieving an effective balance between exploration and utilization. Finally, this invention employs a two-stage progressive optimization strategy. The first stage rapidly filters candidate parameters with fewer training rounds, while the second stage accurately evaluates the optimal parameters with more training rounds, significantly reducing computational costs while ensuring optimization accuracy. This invention organically integrates a category-aware dynamic weighted loss function with an elite collaborative search algorithm, significantly improving the accuracy of poultry health status identification. It boasts advantages such as good parameter adaptability, high computational efficiency, and reliable identification results, and can be widely applied to automatic monitoring of poultry health status in intelligent farming scenarios. Attached Figure Description

[0063] To more clearly illustrate the technical solutions of the embodiments of the present invention, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of the present invention and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained from these drawings without creative effort.

[0064] Figure 1 This is a flowchart of an intelligent pattern recognition method for poultry health status based on deep learning, provided by an embodiment of the present invention.

[0065] Figure 2 This is a flowchart of the calculation of the category-aware dynamic weighted loss function provided by an embodiment of the present invention;

[0066] Figure 3 This is a flowchart of the calculation of the category-aware elite collaborative search algorithm provided in the embodiments of the present invention;

[0067] Figure 4 This is a standard ViT classification confusion matrix diagram provided in the embodiments of the present invention;

[0068] Figure 5 This is a classification confusion matrix diagram of the ViT-CADWL method provided in the embodiments of the present invention;

[0069] Figure 6 This is a classification confusion matrix diagram of the (ViT-CADWL-CAECS) method provided in the embodiments of the present invention. Detailed Implementation

[0070] Example:

[0071] A deep learning-based intelligent pattern recognition method for poultry health status, characterized by the following steps:

[0072] Step S1: Obtain poultry feces image dataset and health status labels;

[0073] Step S2: Construct a baseline deep learning model for poultry health status recognition based on visual Transformer;

[0074] Step S3: Construct a dynamic weighted loss function; in the dynamic weighted loss function, the weighting coefficients of each category are dynamically determined by the weighted fusion result of the average loss of the current batch of that category and the category frequency distribution, and are smoothed by exponential moving average;

[0075] Step S4: The swarm intelligence optimization algorithm is used to perform two-stage optimization of the hyperparameters in the dynamic weighted loss function to obtain the optimal hyperparameter combination. The swarm intelligence optimization algorithm contains N elite individuals, each elite individual corresponds to a category, and the F1 score corresponding to the category is used as the individual's exclusive fitness function. Each elite individual updates its position through historical gradient estimation and group cooperation information to realize parallel search and collaborative optimization of hyperparameters.

[0076] Step S5: Based on the optimal hyperparameter combination, train the baseline deep learning model using the dynamic weighted loss function to obtain the target deep learning model;

[0077] Step S6: Input the poultry feces image to be identified into the target deep learning model and output the health status identification result.

[0078] Furthermore, in step S3, the weighted loss function is a category-aware dynamic weighted loss function, which determines the weighting coefficients for each category through the following steps:

[0079] Step S31: Obtain the number N of samples in each category in the current training batch. c ;

[0080] Step S32: Calculate the average cross-entropy loss l for each category in the current batch. c ;

[0081] l c =1 / B c ×Σ i:yi =c (-log(p(y i |x i )))

[0082] Where i is the sample number in the current batch, x i For the first i samples, y i Let B be the true class label of the i-th sample. c p(y) represents the number of samples of category c in the current batch. i |x i ) represents the model for sample x i Predicted as true label y i The probability of;

[0083] Step S33: Based on the average loss of each category c Loss perception weights are calculated using temperature scaling:

[0084] w c loss =exp(l c / τ) / (Σ j=1:C(exp(l j / τ)))×C

[0085] Among them, w c loss Let τ be the loss perception weight for category c, where C is the total number of categories and τ is the temperature coefficient.

[0086] Step S34: Based on the number of samples N for each category c Calculate the frequency-aware weight w c freq :

[0087] w c freq =1 / N c / (Σ j=1:C (1 / N j ))×C

[0088] Step S35: Adaptively fuse the loss-aware weights and frequency-aware weights to obtain the initial weighting coefficients W for each category. c,ini and to W c,ini After normalization, the final weighted coefficients W for each category are obtained. c :

[0089] W c,ini =α×w c loss +(1-α)×w c freq

[0090] W c = W c,ini / Σ j=1:C (W c,ini )×C

[0091] Where α is the balance coefficient, used to control the fusion ratio of loss perception and frequency perception;

[0092] Step S36: Smooth the weighting coefficients of each category using an exponential moving average to obtain the final smoothed weighting coefficients for each category:

[0093] O c (t)=β×O c (t-1)+(1-β)×W c (t)

[0094] Among them, O c (t) and O c (t-1) represents the final smoothing weighting coefficient of category c in the t-th and t-1-th iterations, β is the momentum coefficient, and W c (t) represents the weighting coefficient for the t-th iteration.

[0095] Step S37: Use the final smoothing weighting coefficients to weight the standard cross-entropy loss function to obtain a category-aware dynamic weighted loss function:

[0096] L CADWL =1 / B×Σ i=1:B (O yi ×-log(p(y i |x i )))

[0097] Where B is the batch size, and O yi The sample x obtained in step S36 i Category y i The smoothing weighting coefficients.

[0098] Furthermore, in step S35, the balance coefficient α is adaptively adjusted according to the training progress:

[0099] α(e) = α0 × (1 - 0.3e / T)

[0100] Where α0 is the initial balance coefficient, e is the current training epoch, and T is the preset maximum training epoch; that is, in the early stage of training, frequency-aware weights are more relied upon to focus on the minority class, while in the later stage of training, loss-aware weights are more relied upon for fine-tuning. The balance coefficient α adaptively decays with the training progress, so that in the early stage of training, frequency-aware weights dominate to fully focus on minority class samples, while in the later stage of training, loss-aware weights dominate to fine-tune the decision boundaries of each class, realizing the automatic and smooth transfer of optimization focus.

[0101] The aforementioned category-aware dynamic weighted loss function accurately perceives the learning difficulty of each category by calculating the average loss from the overall category level rather than relying on the confidence of a single sample. By adaptively fusing loss-aware weights and frequency-aware weights and combining them with exponential moving average smoothing, it ensures sufficient attention to the minority classes in the early stages of training and ensures the stable evolution of the weighting coefficients during training, avoiding training instability caused by drastic fluctuations in weights.

[0102] Furthermore, in step S4, the swarm intelligence optimization algorithm is a category-aware elite collaborative search algorithm, specifically including the following steps:

[0103] Step S41: Initialize a heterogeneous elite population: Randomly generate N elite individuals within the hyperparameter search space. The number of elite individuals N is equal to the number of classes in the dataset, and each elite individual i uniquely corresponds to a class c. i and with the F1 score F of that category ci (θ) serves as the individual's fitness function.

[0104] Step S42: Perform an initial evaluation of the objective function for each elite individual and record the initial position θ of each elite individual. i (0) and the initial fitness value, and store them in the evaluation history of the elite;

[0105] Step S43: Parallel Search Update: Each elite individual i updates its position according to its own fitness function and group cooperation information, following the dual-drive position update formula:

[0106] θ i (t+1)= θ i (t)+ η(t)×▽F ci h (θ i (t))+ κ(t)×Σ j≠i ω ij ×(θ j (t)- θ i (t))

[0107] Where, θ i (t) represents the position of the i-th elite individual in the t-th iteration, ▽F ci h (θ i (t) represents the gradient direction of the fitness function estimated based on historical evaluation data, fitted using local linear regression; η(t) is the individual driving force coefficient, κ(t) is the cooperative driving force coefficient, and ω ij Let J be the collaboration weight between elite individual j and elite individual i.

[0108] The cooperation weight ω ij The fitness value F of elite individual j in the current iteration cj And its distance from individual i in the search space together determine:

[0109] ω ij =exp(-d ij 2 / 2σ 2 )×F cj / (Σ k≠i exp(-d ik 2 / 2σ 2 )×F ck )

[0110] Where, d ij Let d be the Euclidean distance between individual i and individual j in the search space. ik Let σ be the Euclidean distance between individual i and elite individual k in the search space, σ be the distance scale parameter, and ω be the collaboration weight. ij Satisfy Σ j≠i ω ij=1;F ck This represents the fitness value of the k-th elite individual in the current iteration.

[0111] The collaborative weights take into account both the distance between elite individuals in the search space and their fitness level, so that elite individuals that are close to each other and have good performance have a stronger pulling effect on other individuals, thus balancing the local density and global optimality of the search space.

[0112] In the dual-drive position update mechanism, the dedicated drive guides elite individuals to search in the direction of performance improvement of the category they are responsible for, while the collaborative drive pulls each elite individual to move closer to the high fitness region; the two drives adapt to the rise and fall of each other as the iteration process progresses, achieving global collaborative convergence while ensuring balanced optimization of performance of each category.

[0113] Step S44: Evaluate the objective function for the updated elite individuals, and update the position, fitness value and evaluation history of each elite individual;

[0114] Step S45: Repeat steps S43 to S44 until the preset number of iterations is reached. Each elite individual outputs the hyperparameter combination that maximizes the F1 score of its responsible category. After summarizing and removing duplicates, a candidate parameter set is formed.

[0115] Furthermore, in step S43, the dedicated driving force coefficient η(t) and the cooperative driving force coefficient κ(t) are adaptively adjusted as the iteration progresses:

[0116] η(t) = η0 × (1 - t / T) max )

[0117] κ(t) = κ0 × t / T max

[0118] Where t is the current iteration number, T max To preset the maximum number of iterations, η0 and κ0 are the initial exclusive driving force coefficient and the initial collaborative driving force coefficient, respectively. That is, in the early stage of optimization, exclusive driving force is the main factor, and each elite individual independently explores the optimal region of its own category; in the later stage of optimization, collaborative driving force is the main factor, and each elite individual influences each other to promote the synergistic integration of candidate parameters.

[0119] The aforementioned category-aware elite collaborative search algorithm overcomes the shortcomings of traditional swarm intelligence algorithms, which sacrifice some category performance due to all individuals sharing the same fitness function, by setting up a heterogeneous elite population equal to the number of categories and assigning each elite to a specific category. It provides a dedicated driving force through historical gradient estimation, utilizing historical search information without additional computational cost. It achieves information sharing among elite individuals through a collaborative driving force weighted by distance and fitness, and dynamically adjusts the weights of the two driving forces during the iteration process, achieving an effective balance between sufficient exploration in the early stage of optimization and refined utilization in the later stage.

[0120] Furthermore, in step S4, the two-stage optimization specifically includes:

[0121] Phase 1: The swarm intelligence optimization algorithm described in step S4 is used to search for hyperparameters. The F1 score of each elite individual in the category they are responsible for is used as the exclusive fitness function. The model training and evaluation of each candidate hyperparameter combination is carried out for a preset number of rounds to generate a candidate parameter set S.

[0122] The second stage: With the overall accuracy as the optimization objective, the model training evaluation of each candidate hyperparameter combination is carried out on the candidate parameter set S for a preset second round, and the hyperparameter combination that achieves the highest overall accuracy is selected as the final optimal parameter.

[0123] The number of preset first rounds is less than the number of preset second rounds.

[0124] The two-stage progressive optimization strategy described above employs two phases: the first phase rapidly coarsely filters the hyperparameter space with fewer training epochs, generating a candidate parameter set and significantly reducing the computational cost of hyperparameter search; the second phase performs fine-grained evaluation on the candidate set with more training epochs, ensuring the optimality of the final parameters. This strategy achieves a balance between search efficiency and optimization accuracy with limited computational resources.

[0125] Furthermore, in step S43, the method for estimating the gradient direction of the fitness function based on historical evaluation data is as follows:

[0126] Select the position θ from the evaluation history. i (t) The K most recent historical points are used to construct a local linear model:

[0127] f(θ)≈▽F ci h ·θ+b

[0128] Among them, ▽F ci hThe gradient direction of the fitness function is estimated, and b is the bias term. The coefficients of the local linear model are solved by the least squares method, and the slope vector is taken as the estimated value of the gradient direction. When the K historical points are collinear or insufficient, the estimated value of the gradient direction is set to the zero vector.

[0129] The method of the present invention will be explained below using a specific case of poultry health status identification as an example.

[0130] The specific implementation process is as follows:

[0131] like Figure 1 As shown, a deep learning-based intelligent pattern recognition method for poultry health status includes the following steps:

[0132] Step S1: Obtain poultry feces image dataset and health status labels;

[0133] In this embodiment, the experimental data comes from a dataset of chicken feces images collected from a large-scale poultry farm. This dataset includes four health status categories: healthy, coccidiosis, salmonellosis, and Newcastle disease, totaling 8067 valid images. The sample distribution for each category is as follows: Salmonella 2625 images, coccidiosis 2476 images, healthy 2404 images, and Newcastle disease 562 images. Newcastle disease samples account for approximately 7%, constituting a minority class, while the other three categories are the majority classes, resulting in a significant imbalance in sample size among the categories. In this embodiment, the dataset is divided into training, validation, and test sets in a 7:1.5:1.5 ratio. A fixed random seed (seed=42) is used to ensure the repeatability of the partitioning. The training set is used for model parameter learning, the validation set is used for hyperparameter selection and early stopping detection, and the test set is used for final model performance evaluation.

[0134] Step S2: Construct a baseline deep learning model for poultry health status recognition based on visual Transformer;

[0135] In this embodiment, the baseline model adopts a standard visual Transformer architecture. The image patch size is 16×16 pixels, and the embedding dimension is 384. The Transformer encoder consists of 6 stacked layers, each containing a 6-head self-attention mechanism and an MLP (expansion ratio of 4), with a Dropout rate of 0.1.

[0136] Step S3: Construct a dynamic weighted loss function; in the dynamic weighted loss function, the weighting coefficients of each category are dynamically determined by the weighted fusion result of the average loss of the current batch of that category and the category frequency distribution, and are smoothed by exponential moving average;

[0137] The calculation process of the category-aware dynamic weighted loss function is as follows: Figure 2 As shown.

[0138] Step S4: The swarm intelligence optimization algorithm is used to perform two-stage optimization of the hyperparameters in the dynamic weighted loss function to obtain the optimal hyperparameter combination. The swarm intelligence optimization algorithm contains N elite individuals, each elite individual corresponds to a category, and the F1 score corresponding to the category is used as the individual's exclusive fitness function. Each elite individual updates its position through historical gradient estimation and group cooperation information to realize parallel search and collaborative optimization of hyperparameters.

[0139] The computational process of the category-aware Collaborative Elite Search (CAECS) algorithm is as follows: Figure 3 As shown.

[0140] In this embodiment, the CAECS algorithm iterates 10 times, and the temperature coefficient τ ranges from [0.5, 5.0]; the balance coefficient α controls the fusion ratio of loss-perceived weights and frequency-perceived weights, and ranges from [0.2, 0.8]. In the CAECS algorithm, N=4, and T... max =10, the first stage of evaluation training rounds is 5, the second stage of training rounds is 50, K=3, η0=0.8, κ0=0.6, σ=1.0.

[0141] Step S5: Based on the optimal hyperparameter combination, train the baseline deep learning model using the dynamic weighted loss function to obtain the target deep learning model;

[0142] The model was trained using the AdamW optimizer with an initial learning rate of 1×10⁻ 4 The weight decay coefficient is 0.05, the batch size is 32, the training rounds are 50, and the learning rate is scheduled using a cosine annealing strategy.

[0143] Step S6: Input the poultry feces image to be identified into the target deep learning model and output the health status identification result.

[0144] To verify the advantages of the method of this invention, this case study compared the standard ViT method, the ViT method using a dynamically weighted loss function (ViT-CADWL), and the proposed method (ViT-CADWL-CAECS), recording their accuracy, precision, recall, and F1 score. The results are shown in Table 1. Simultaneously, the confusion matrices of the classification results of the standard ViT method, the CADWL-ViT method, and the proposed method are shown in Table 1. Figure 4 , Figure 5 , Figure 6 As shown:

[0145] Table 1 Comparative Experimental Results

[0146] Standard Vit 89.43 89.66 89.43 0.8931 ViT-CADWL 90.17 90.49 90.17 0.9020 The method of this invention (ViT-CADWL-CAECS) 90.59 90.68 90.59 0.9061

[0147] Experimental results show that in this case study of health identification based on poultry manure, the CADWL-ViT method outperforms the standard ViT method, demonstrating the advantages of the CADWL function. Furthermore, the method of this invention, by incorporating the CAECS algorithm, further improves the identification performance, fully verifying the advantages of the method of this invention.

Claims

1. A method for intelligent pattern recognition of poultry health status based on deep learning, characterized in that, Includes the following steps: Step S1: Obtain poultry feces image dataset and health status labels; Step S2: Construct a baseline deep learning model for poultry health status recognition based on visual Transformer; Step S3: Construct a dynamic weighted loss function; in the dynamic weighted loss function, the weighting coefficients of each category are dynamically determined by the weighted fusion result of the average loss of the current batch of that category and the category frequency distribution, and are smoothed by exponential moving average; Step S4: The swarm intelligence optimization algorithm is used to perform two-stage optimization of the hyperparameters in the dynamic weighted loss function to obtain the optimal hyperparameter combination. The swarm intelligence optimization algorithm contains N elite individuals, each elite individual corresponds to a category, and the F1 score corresponding to the category is used as the individual's exclusive fitness function. Each elite individual updates its position through historical gradient estimation and group cooperation information to realize parallel search and collaborative optimization of hyperparameters. Step S5: Based on the optimal hyperparameter combination, train the baseline deep learning model using the dynamic weighted loss function to obtain the target deep learning model; Step S6: Input the image of the poultry feces to be identified into the target deep learning model and output the health status identification result.

2. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 1, characterized in that, In step S3, the weighted loss function is a category-aware dynamic weighted loss function, which determines the weighting coefficients for each category through the following steps: Step S31: Obtain the number N of samples in each category in the current training batch. c ; Step S32: Calculate the average cross-entropy loss l for each category in the current batch. c ; l c =1 / B c ×Σ i:yi =c (-log(p(y i ∣x i ))) Where i is the sample number in the current batch, x i For the i-th sample, y i Let B be the true class label of the i-th sample. c p(y) represents the number of samples of category c in the current batch. i |x i ) represents the model for sample x i Predicted as true label y i The probability of; Step S33: Based on the average loss of each category c Loss perception weights are calculated using temperature scaling: w c loss =exp(l c / t) / (S j=1:C (exp(l j / τ)))×C Among them, w c loss Let τ be the loss perception weight for category c, where C is the total number of categories and τ is the temperature coefficient. Step S34: Based on the number of samples N for each category c Calculate the frequency-aware weight w c freq : w c freq =1 / N c / (S j=1:C (1 / N j ))×C Step S35: Adaptively fuse the loss-aware weights and frequency-aware weights to obtain the initial weighting coefficients W for each category. c,ini and to W c,ini After normalization, the final weighted coefficients W for each category are obtained. c : W c,ini =α×w c loss +(1-a)×w c freq W c = W c,ini / Σ j=1:C (W c,ini )×C Where α is the balance coefficient, used to control the fusion ratio of loss perception and frequency perception; Step S36: Smooth the weighting coefficients of each category using an exponential moving average to obtain the final smoothed weighting coefficients for each category: O c (t)=β×O c (t-1)+(1-β)×W c (t) Among them, O c (t) and O c (t-1) represents the final smoothing weighting coefficient of category c in the t-th and t-1-th iterations, β is the momentum coefficient, and W c (t) represents the weighting coefficient for the t-th iteration. Step S37: Use the final smoothing weighting coefficients to weight the standard cross-entropy loss function to obtain a category-aware dynamic weighted loss function: L CADWL =1 / B×Σ i=1:B (O yi ×-log(p(y i |x i ))) Where B is the batch size, and O yi The sample x obtained in step S36 i Category y i The smoothing weighting coefficients.

3. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 2, characterized in that, In step S35, the balance coefficient α is adaptively adjusted according to the training progress: α(e) = α0 × (1 - 0.3e / T) Where α0 is the initial balance coefficient, e is the current training round, and T is the preset maximum training round; that is, in the early stage of training, frequency-aware weights are more relied upon to focus on the minority class, while in the later stage of training, loss-aware weights are more relied upon for fine-tuning.

4. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 1, characterized in that, In step S4, the swarm intelligence optimization algorithm is a category-aware elite collaborative search algorithm, which specifically includes the following steps: Step S41: Initialize a heterogeneous elite population: Randomly generate N elite individuals within the hyperparameter search space. The number of elite individuals N is equal to the number of classes in the dataset, and each elite individual i uniquely corresponds to a class c. i and with the F1 score F of that category ci (θ) serves as the individual's fitness function. Step S42: Perform an initial evaluation of the objective function for each elite individual and record the initial position θ of each elite individual. i (0) and the initial fitness value, and store them in the evaluation history of the elite; Step S43: Parallel Search Update: Each elite individual i updates its position according to its own fitness function and group cooperation information, following the dual-drive position update formula: i i (t+1)= θ i (t)+ η(t)×▽F ci h (i i (t))+ k(t)×Σ j≠i oh ij ×(θ j (t)- θ i (t)) Where, θ i (t) represents the position of the i-th elite individual in the t-th iteration, ▽F ci h (θ i (t) represents the gradient direction of the fitness function estimated based on historical evaluation data, fitted using local linear regression; η(t) is the individual driving force coefficient, κ(t) is the cooperative driving force coefficient, and ω ij Let J be the collaboration weight between elite individual j and elite individual i. The cooperation weight ω ij The fitness value F of elite individual j in the current iteration cj And its distance from individual i in the search space together determine: oh ij =exp(-d ij 2 / 2σ 2 )×F cj / (S k≠i exp(-d ik 2 / 2σ 2 )×F ck ) Where, d ij Let d be the Euclidean distance between individual i and individual j in the search space. ik Let σ be the Euclidean distance between individual i and elite individual k in the search space, σ be the distance scale parameter, and ω be the collaboration weight. ij Satisfy Σ j≠i ω ij =1;F ck This represents the fitness value of the k-th elite individual in the current iteration. Step S44: Evaluate the objective function for the updated elite individuals, and update the position, fitness value and evaluation history of each elite individual; Step S45: Repeat steps S43 to S44 until the preset number of iterations is reached. Each elite individual outputs the hyperparameter combination that maximizes the F1 score of its responsible category. After summarizing and removing duplicates, a candidate parameter set is formed.

5. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 4, characterized in that, In step S43, the dedicated driving force coefficient η(t) and the cooperative driving force coefficient κ(t) are adaptively adjusted as the iteration progresses: η(t)=η0×(1-t / T max ) κ(t)=κ0×t / T max Where t is the current iteration number, T max To preset the maximum number of iterations, η0 and κ0 are the initial exclusive driving force coefficient and the initial collaborative driving force coefficient, respectively. That is, in the early stage of optimization, exclusive driving force is the main factor, and each elite individual independently explores the optimal region of its own category; in the later stage of optimization, collaborative driving force is the main factor, and each elite individual guides each other to promote the synergistic integration of candidate parameters.

6. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 1, characterized in that, In step S4, the two-stage optimization specifically includes: Phase 1: The swarm intelligence optimization algorithm described in step S4 is used to search for hyperparameters. The F1 score of each elite individual in the category they are responsible for is used as the exclusive fitness function. The model training and evaluation of each candidate hyperparameter combination is carried out for a preset number of rounds to generate a candidate parameter set S. The second stage: With the overall accuracy as the optimization objective, the model training evaluation of each candidate hyperparameter combination is carried out on the candidate parameter set S for a preset second round, and the hyperparameter combination that achieves the highest overall accuracy is selected as the final optimal parameter. The number of preset first rounds is less than the number of preset second rounds.

7. The intelligent pattern recognition method for poultry health status based on deep learning as described in claim 4, characterized in that, In step S43, the method for estimating the gradient direction of the fitness function based on historical evaluation data is as follows: Select the position θ from the evaluation history. i (t) The K most recent historical points are used to construct a local linear model: f(θ)≈▽F ci h ·θ+b Among them, ▽F ci h The gradient direction of the fitness function is estimated, and b is the bias term. The coefficients of the local linear model are solved by the least squares method, and the slope vector is taken as the estimated value of the gradient direction. When the K historical points are collinear or insufficient, the estimated value of the gradient direction is set to the zero vector.