Image classification method and device based on double-layer optimization neural network, equipment and storage medium

By employing a bilayer optimization and neurodynamics-based image classification method, the coupling problem between perturbation and parameter update in deep neural networks for industrial image classification tasks is solved, thereby improving the model's generalization ability and stability under complex working conditions.

CN121482507BActive Publication Date: 2026-05-12CENT SOUTH UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
CENT SOUTH UNIV
Filing Date
2026-01-07
Publication Date
2026-05-12

AI Technical Summary

Technical Problem

In industrial image classification tasks, there is a coupling problem between perturbation and parameter update during deep neural network training, resulting in insufficient model generalization ability and stability, especially under complex working conditions.

Method used

An image classification method based on bi-layer optimization and neurodynamics is adopted. An initial image classification model is constructed, and a reference image classification model is obtained by training it using a training set. The performance is evaluated and parameters are adjusted using a validation set to form the final industrial image classification model.

Benefits of technology

It alleviates the coupling problem between perturbation and parameter update during deep neural network training, reduces sensitivity to hyperparameters, and improves the model's generalization ability and stability under complex conditions.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121482507B_ABST
    Figure CN121482507B_ABST
Patent Text Reader

Abstract

The application discloses an image classification method and device based on a double-layer optimization neural network, equipment and a storage medium, relates to the technical field of industrial image classification, and comprises the following steps: preprocessing historical industrial image data and dividing the historical industrial image data into a training set and a verification set with category labels; an initial image classification model is constructed based on a target neural network structure, a preset loss function, initial network parameters and an initial disturbance vector; then, the model is trained by using the training set and through double-layer optimization and a neural dynamics mechanism, so that a reference image classification model is obtained; the performance of the reference model is evaluated and the parameters are adjusted according to the verification set, so that a final industrial image classification model is obtained; and a new industrial image is input into the model to obtain a classification result. The application can relieve the coupling problem of disturbance and parameter updating during the training of a deep neural network in an industrial image classification task, reduce the sensitivity to hyperparameters, and improve the generalization ability and stability of the model under complex working conditions.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of industrial image classification technology, and in particular to image classification methods, apparatus, devices and storage media based on two-layer optimized neural networks. Background Technology

[0002] With the widespread application of deep learning technology in intelligent manufacturing, deep neural networks have made significant progress in industrial image classification tasks and have been deployed in various typical scenarios such as automatic grading of metal ores, surface defect detection of metallurgical products, and identification of the operating status of electrolytic cells. As the scale of model parameters continues to expand, overparameterized structures are gradually becoming the norm. How to improve the generalization ability of models in complex industrial environments has become a key issue for intelligent vision systems.

[0003] In industrial settings, image data often suffers from low resolution, uneven lighting, complex backgrounds, and severe noise interference, leading to significant discrepancies between training data and real-world application data. Traditional local gradient-based optimization methods struggle to perceive the geometric characteristics of the loss function, easily getting trapped in sharp minima, resulting in overfitting and reduced generalization performance. To alleviate this problem, sharpness-aware minimization methods guide the model to converge to a flat minima region by minimizing the worst-case loss function in the neighborhood of parameter perturbations, thus improving generalization performance to some extent. However, this method suffers from coupling between perturbations and parameter updates during optimization, making it sensitive to hyperparameters and lacking stability under non-stationary training conditions. These limitations are particularly pronounced in complex and noisy industrial scenarios. Therefore, addressing the coupling between perturbations and parameter updates during deep neural network training, reducing sensitivity to hyperparameters, and improving the model's generalization ability and stability under complex conditions are urgent problems to be solved in industrial image classification tasks. Summary of the Invention

[0004] The purpose of this application is to provide an image classification method, apparatus, device, and storage medium based on a two-layer optimized neural network, aiming to solve the technical problem of how to alleviate the coupling problem between perturbation and parameter update during deep neural network training in industrial image classification tasks, reduce the sensitivity to hyperparameters, and improve the generalization ability and stability of the model under complex working conditions.

[0005] To achieve the above objectives, this application proposes an image classification method based on a two-layer optimized neural network, the method comprising:

[0006] Historical industrial image data is preprocessed to obtain a training set and a validation set, both of which contain corresponding category labels.

[0007] Based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector, construct an initial image classification model;

[0008] Based on the bi-layer optimization and neurodynamics mechanism, the initial image classification model is trained according to the training set to obtain the reference image classification model;

[0009] Based on the validation set, the performance of the reference image classification model is evaluated and the parameters are adjusted to obtain the industrial image classification model.

[0010] The newly added industrial images are input into the industrial image classification model to obtain the classification results.

[0011] In one embodiment, the step of training the initial image classification model based on the training set to obtain a reference image classification model, using a two-layer optimization and neurodynamics mechanism, includes:

[0012] A batch of training samples and their corresponding category labels are selected from the training set and input into the initial image classification model for forward propagation to obtain the predicted probability distribution.

[0013] Calculate the loss value between the predicted probability distribution and the category label based on the preset loss function;

[0014] Add the initial network parameters to the initial perturbation vector to obtain the perturbed parameter points;

[0015] Based on the loss value, calculate the first gradient of the initial image classification model corresponding to the parameter points after the perturbation and the second gradient corresponding to the initial perturbation vector;

[0016] The initial image classification model is trained using the fast timescale update strategy, the second gradient, the neural dynamics update equation, the slow timescale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model.

[0017] In one embodiment, the step of training the initial image classification model according to the fast time-scale update strategy, the second gradient, the neural dynamics update equation, the slow time-scale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model includes:

[0018] The initial perturbation vector is updated according to the fast timescale update strategy, combined with the second gradient and the neural dynamics update equation, to obtain the updated perturbation vector;

[0019] Based on the preset norm constraint, the updated perturbation vector is projected to obtain the target perturbation vector;

[0020] The updated network parameters are obtained by updating the initial network parameters according to the slow time scale update strategy and the first gradient.

[0021] The updated network parameters and the target perturbation vector are used as the initial network parameters and initial perturbation vector for the next iteration, respectively. The steps of selecting a batch of training samples and the corresponding category labels from the training set and inputting them into the initial image classification model for forward propagation to obtain the predicted probability distribution are repeated until the loss value converges or reaches the preset number of training rounds to obtain the reference image classification model.

[0022] In one embodiment, the step of calculating the first gradient of the initial image classification model corresponding to the parameter points after the perturbation and the second gradient corresponding to the initial perturbation vector based on the loss value includes:

[0023] Based on the backpropagation algorithm, the partial derivative of the loss value with respect to the perturbed parameter points is calculated to obtain the original gradient;

[0024] The original gradient is subjected to gradient clipping to obtain the clipped gradient;

[0025] The clipped gradient is used as the first gradient corresponding to the perturbated parameter point;

[0026] Calculate the partial derivative of the loss value with respect to the initial perturbation vector to obtain the second gradient corresponding to the initial perturbation vector.

[0027] In one embodiment, the step of updating the initial perturbation vector according to a fast timescale update strategy, combining the second gradient and the neural dynamics update equation, to obtain the updated perturbation vector includes:

[0028] Determine the activation function in the neurodynamic update equation, wherein the activation function is used to limit the range of values ​​of the perturbation vector;

[0029] The second gradient is input into the activation function for nonlinear transformation to obtain the transformed gradient;

[0030] According to the neural dynamics update equation, the initial perturbation vector is added to the transformed gradient to obtain the intermediate perturbation vector;

[0031] Subtracting the initial perturbation vector from the intermediate perturbation vector yields the perturbation update increment;

[0032] The perturbation update increment is multiplied by a preset fast timescale learning rate, and then added to the initial perturbation vector to obtain the updated perturbation vector.

[0033] In one embodiment, the step of updating the initial network parameters according to a slow time-scale update strategy and in combination with the first gradient to obtain the updated network parameters includes:

[0034] The cosine annealing strategy is used to adjust the preset slow time scale learning rate to obtain the target slow time scale learning rate.

[0035] Multiply the first gradient by the preset weight decay coefficient to obtain the decayed gradient;

[0036] Based on a preset momentum factor, the historical gradient cumulative value is calculated. The historical gradient cumulative value refers to the value formed by weighting and accumulating the first gradient calculated in each iteration according to the preset momentum factor in each iteration before the current iteration.

[0037] The current gradient accumulation value is obtained by adding the decayed gradient to the historical gradient accumulation value.

[0038] Multiply the current accumulated gradient value by the target slow timescale learning rate to obtain the gradient update amount;

[0039] The updated network parameters are obtained by subtracting the gradient update amount from the initial network parameters.

[0040] In one embodiment, the neurodynamic update equation is expressed as follows:

[0041]

[0042] in, It refers to the perturbation vector during the k-th iteration. It refers to the perturbation vector after the k-th round of fast time-scale updates. This refers to the preset fast timescale learning rate. This refers to the second gradient. This refers to the perturbation vector gradient operator, This refers to the initial network parameters during the k-th iteration. This is the activation function, used to ensure that the perturbation vector is within the preset norm constraint.

[0043] Furthermore, to achieve the above objectives, this application also proposes an image classification device based on a two-layer optimized neural network, the device comprising:

[0044] The data preprocessing module is used to preprocess historical industrial image data to obtain a training set and a validation set, both of which contain corresponding category labels.

[0045] The model building module is used to build an initial image classification model based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector.

[0046] The model training module is used to train the initial image classification model based on the training set using a two-layer optimization and neurodynamics mechanism to obtain a reference image classification model.

[0047] The model validation module is used to evaluate the performance and adjust the parameters of the reference image classification model based on the validation set to obtain an industrial image classification model.

[0048] The image classification module is used to input newly added industrial images into the industrial image classification model to obtain classification results.

[0049] Furthermore, to achieve the above objectives, this application also proposes an image classification device based on a two-layer optimized neural network, the device comprising: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the image classification method based on the two-layer optimized neural network described above.

[0050] In addition, to achieve the above objectives, this application also proposes a storage medium, which is a computer-readable storage medium, on which a computer program is stored, and when the computer program is executed by a processor, it implements the steps of the image classification method based on a two-layer optimized neural network as described above.

[0051] In addition, to achieve the above objectives, this application also provides a computer program product, which includes a computer program that, when executed by a processor, implements the steps of the image classification method based on a two-layer optimized neural network as described above.

[0052] One or more technical solutions proposed in this application have at least the following technical effects:

[0053] First, historical industrial image data is preprocessed to form training and validation sets containing category labels, providing the model with well-structured and consistent quality supervision data, avoiding the impact of noise or uneven distribution of the original data on training results. Next, based on the selected target neural network structure, the system constructs a complete initial image classification model by combining a preset loss function, initialized network parameters, and an initial perturbation vector, ensuring a reasonable and reproducible starting point for training. Subsequently, the system employs a two-layer optimization and neurodynamics mechanism to train the initial model using the training set, thereby obtaining a reference image classification model. This process effectively decouples the strong dependency between perturbation generation and parameter updates. Then, the system uses the validation set to evaluate the performance of the reference model and adjusts hyperparameters or selects the optimal model version based on the evaluation results to obtain the final industrial image classification model, ensuring its reliability on unseen data. Finally, the system inputs new industrial images into the model and outputs the corresponding classification results, achieving automatic discrimination in real-world scenarios. This application can alleviate the coupling problem between perturbation and parameter updates during deep neural network training in industrial image classification tasks, reduce sensitivity to hyperparameters, and improve the model's generalization ability and stability under complex working conditions. Attached Figure Description

[0054] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.

[0055] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, for those skilled in the art, other drawings can be obtained based on these drawings without creative effort.

[0056] Figure 1 This is a flowchart illustrating an embodiment of the image classification method based on a two-layer optimized neural network provided in this application.

[0057] Figure 2 This is a flowchart illustrating Embodiment 2 of the image classification method based on a two-layer optimized neural network provided in this application;

[0058] Figure 3 A simplified flowchart illustrating the image classification method based on a two-layer optimized neural network provided in Embodiment 2 of this application;

[0059] Figure 4 This is a schematic diagram of the module structure of the image classification device based on a two-layer optimized neural network according to an embodiment of this application;

[0060] Figure 5This is a schematic diagram of the device structure of the hardware operating environment involved in the image classification method based on a two-layer optimized neural network in the embodiments of this application.

[0061] The purpose, features, and advantages of this application will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0062] It should be understood that the specific embodiments described herein are merely illustrative of the technical solutions of this application and are not intended to limit this application.

[0063] To better understand the technical solution of this application, a detailed description will be provided below in conjunction with the accompanying drawings and specific implementation methods.

[0064] It should be noted that the executing entity of this application embodiment can be a computing service device with data processing, network communication, and program execution functions, such as a tablet computer, personal computer, or mobile phone, or an electronic device or image classification system capable of realizing the above functions. The following uses an image classification system as an example to describe this embodiment and the subsequent embodiments.

[0065] Based on this, embodiments of this application provide an image classification method based on a two-layer optimized neural network, referring to... Figure 1 , Figure 1 This is a flowchart illustrating the first embodiment of the image classification method based on a two-layer optimized neural network according to this application.

[0066] In this embodiment, the image classification method based on a two-layer optimized neural network includes steps S10 to S50:

[0067] Step S10: Preprocess the historical industrial image data to obtain a training set and a validation set, both of which contain corresponding category labels;

[0068] Step S20: Construct an initial image classification model based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector;

[0069] Step S30: Based on the two-layer optimization and neurodynamics mechanism, the initial image classification model is trained according to the training set to obtain the reference image classification model;

[0070] Step S40: Based on the validation set, the reference image classification model is evaluated for performance and its parameters are adjusted to obtain an industrial image classification model;

[0071] Step S50: Input the newly added industrial image into the industrial image classification model to obtain the classification result.

[0072] It should be noted that historical industrial image data refers to the collection of original images collected and accumulated during actual industrial production processes for model training and validation. It typically covers visual samples under different working conditions, equipment states, or product types, and can originate from scenarios such as industrial metal ores, metallurgical surface defects, and electrolytic cell monitoring images. A high-noise / perturbation image library and a label library for each image are created separately, i.e.:

[0073] ,

[0074] in, Represents historical industrial image data, Represents the total number of samples. This represents the input image, with a size of [size missing]. Pixels The number of channels in an industrial image. The height of industrial images. The width of an industrial image. The image category label (one-hot encoded or integer label) corresponding to the input image.

[0075] The training set refers to a subset of labeled images from historical industrial image data, specifically used to optimize the neural network parameters, enabling it to learn effective feature representations and classification capabilities. The validation set refers to another subset of labeled images from historical industrial image data; it does not participate in model parameter updates but is used solely to evaluate model performance, monitor overfitting, and assist in hyperparameter tuning during training. Category labels are manually or automatically assigned category identifiers for each industrial image, used for the target output in supervised learning (e.g., in the scenario of surface defect detection in metallurgical products, categorized into specific defect types such as normal, scratches, dents, and stains). The target neural network architecture refers to a deep neural network architecture used to perform image classification tasks, including but not limited to established mature model architectures such as ResNet-18 (Residual Network-18), MobileNet-V1 (Mobile Network Version 1), DenseNet-121 (Densely Connected Convolutional Network-121), and WRN-28-10 (Wide Residual Network with 28 layers and width factor 10). Let the neural network be a parameterized function mapping. The output will be Taking WRN-28-10 as an example, its structure can be formally described as follows:

[0076]

[0077] in, It refers to the prediction function of the target neural network structure for the input image sample x; Indicates the first Each residual block consists of multiple convolutions, batch normalization (BN), and ReLU activation functions; Indicates function composition; For network depth.

[0078] A pre-defined loss function is a mathematical function selected before model training to measure the difference between the predicted output and the true class label. It typically uses standard classification loss forms such as cross-entropy loss. Initial network parameters. This refers to the initial values ​​assigned to the weights and biases of each layer of the target neural network before training begins. These values ​​are typically generated using random initialization methods (e.g., Xavier initialization or Kaiming initialization). Initial perturbation vector This refers to a small-amplitude perturbation introduced into the network parameter space at the beginning of the optimization process. Its dimension is consistent with the network parameters, and the initial value is usually set as a zero vector or a random vector following a specific distribution (e.g., a zero vector or Gaussian noise with a standard deviation of 0.01). The initial image classification model refers to the untrained, original model instance consisting of the target neural network structure, a preset loss function, initial network parameters, and an initial perturbation vector. Two-layer optimization and neurodynamics mechanisms refer to a training framework that decomposes the parameter update process into two layers of optimization problems. The outer layer optimization aims to find the master parameters that optimize the model's generalization performance, while the inner layer optimization searches for the most unfavorable perturbation in the local neighborhood. The neurodynamics mechanism refers to modeling the parameter evolution process through differential equations or iterative dynamic systems to guide the network to converge to a flat region of the loss surface. The reference image classification model refers to the intermediate model obtained after parameter learning on the training set following a training process based on two-layer optimization and neurodynamics mechanisms, and has not yet been tuned on a validation set. An industrial image classification model refers to an image classification model suitable for practical deployment, finalized after hyperparameter fine-tuning or early stopping selection based on performance feedback from a reference image classification model and incorporating feedback from the validation set. New industrial images refer to real-time or newly acquired industrial scene images input into the industrial image classification model during the model deployment phase that have not participated in training or validation. The classification result refers to the predicted category label output by the industrial image classification model for the newly input industrial image, representing the model's judgment of the image content's category (e.g., classifying it as "crack" or "qualified product").

[0079] It is understood that this embodiment can be used for industrial vision tasks such as metal ore grading, aluminum electrolytic cell operation status identification, and metallurgical surface defect detection.

[0080] First, the image classification system performs preprocessing operations on historical industrial image data, including grayscale normalization, size scaling, noise filtering, and data augmentation. The processed data is then divided into training and validation sets according to a preset ratio (e.g., 8:2) to ensure that each sample retains its original class label for subsequent supervised training and model evaluation. Second, based on a pre-selected target neural network structure, the system loads the corresponding network architecture code, sets a preset loss function (e.g., cross-entropy loss), and generates initial network parameters using standard initialization methods (e.g., Kaiming initialization). The initial perturbation vector is set to a zero vector or a small-amplitude random vector with the same dimension as the network parameters, thus constructing a complete initial image classification model. Then, based on two-layer optimization and neurodynamics mechanisms, the system iteratively trains the initial image classification model using the training set. In each iteration, the inner optimization searches for the perturbation direction that maximizes the loss within the neighborhood of the current parameters, while the outer optimization updates the backbone network parameters based on the loss gradient under this perturbation. Simultaneously, the neurodynamic equation constrains the parameter evolution trajectory, guiding the model to converge to a flat minimum region, ultimately outputting a reference image classification model. Next, the image classification system uses the validation set to perform forward inference on the reference image classification model, calculating its classification accuracy, F1 score, and robustness metrics on the validation set. Based on this, it adjusts hyperparameters such as the learning rate, perturbation radius, or number of early stopping rounds, or selects the model snapshot with the best validation performance, thereby determining the final industrial image classification model. Finally, the image classification system inputs a new industrial image into the industrial image classification model, performs one forward propagation, and outputs the category label to which the image belongs as the classification result, which is used for automatic discrimination and decision-making in real-world industrial scenarios.

[0081] The preset loss function is expressed as follows:

[0082]

[0083] in, This represents the total number of categories in an industrial image classification task. Indicates the first Class label distribution This represents the predicted probability output by softmax. This embodiment employs a label smoothing strategy, by... Convert to and The distribution of this distribution helps improve the robustness of the model. This refers to the preset label smoothing coefficient, which is 0.1 in this embodiment.

[0084] To ensure the priority of inner-layer perturbation evolution, the following is set: and make the learning rate meet and Therefore, we can conclude that... This means that the update rate of the perturbation variable is higher than that of the parameter variable. In practical implementation, this can be set... Among them, the learning rate scaling factor for fast and slow time scales Take the integer value; It refers to the time scale parameter corresponding to the network parameter, which is the parameter that controls the update rhythm of the parameter variable; The time scale parameter corresponding to the disturbance variable is the parameter that controls the update rhythm of the disturbance variable; This refers to a learning rate with a preset slow time scale; This refers to the preset learning rate over a fast time scale.

[0085] This embodiment provides an image classification method based on a two-layer optimized neural network. First, historical industrial image data is preprocessed to form training and validation sets containing category labels, providing the model with well-structured and consistent quality supervision data, avoiding the impact of noise or uneven distribution of the original data on training performance. Next, based on the selected target neural network structure, the system constructs a complete initial image classification model by combining a preset loss function, initialized network parameters, and an initial perturbation vector, ensuring a reasonable and reproducible starting point for training. Subsequently, the system employs a two-layer optimization and neurodynamics mechanism to train the initial model using the training set, thereby obtaining a reference image classification model. This process effectively decouples the strong dependency between perturbation generation and parameter updates. Then, the system uses the validation set to evaluate the performance of the reference model and adjusts hyperparameters or selects the optimal model version based on the evaluation results to obtain the final industrial image classification model, ensuring its reliability on unseen data. Finally, the system inputs new industrial images into the model and outputs the corresponding classification results, achieving automatic discrimination in real-world scenarios. This embodiment can alleviate the coupling problem between perturbation and parameter update during deep neural network training in industrial image classification tasks, reduce sensitivity to hyperparameters, and improve the model's generalization ability and stability under complex working conditions.

[0086] Based on the first embodiment of this application, in the second embodiment of this application, the content that is the same as or similar to that in Embodiment 1 above can be referred to the above description, and will not be repeated hereafter. Based on this, please refer to... Figure 2 , Figure 2 This is a flowchart illustrating the second embodiment of the image classification method based on a two-layer optimized neural network of this application. Step S30 of the image classification method based on a two-layer optimized neural network includes steps S31 to S35:

[0087] Step S31: Select a batch of training samples and their corresponding category labels from the training set, input them into the initial image classification model for forward propagation, and obtain the predicted probability distribution;

[0088] Step S32: Calculate the loss value between the predicted probability distribution and the category label according to the preset loss function;

[0089] Step S33: Add the initial network parameters to the initial perturbation vector to obtain the perturbed parameter points;

[0090] Step S34: Based on the loss value, calculate the first gradient of the initial image classification model corresponding to the parameter points after the perturbation and the second gradient corresponding to the initial perturbation vector;

[0091] Step S35: Train the initial image classification model according to the fast timescale update strategy, the second gradient, the neural dynamics update equation, the slow timescale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model.

[0092] It should be noted that the predicted probability distribution refers to the set of vectors representing the probability of each sample belonging to each class, obtained by transforming the output layer after the initial image classification model performs forward propagation on a batch of input training samples and using an activation function (such as Softmax). The loss value is a measure of the difference between the predicted probability distribution and the corresponding true class label, calculated according to a preset loss function, used to quantify the magnitude of the model's current prediction error. The perturbed parameter point refers to the new parameter value obtained by adding the initial network parameters element-wise to the initial perturbation vector, representing the position after the perturbation is applied within the neighborhood of the original parameters, used to evaluate the sensitivity of the local loss surface. The first gradient is the gradient of the loss value with respect to the perturbed parameter point, i.e., the partial derivative of the loss function with respect to the network backbone parameters at the perturbation location, used to guide the update direction of the main parameters on a slow time scale. The second gradient is the gradient of the loss value with respect to the initial perturbation vector, i.e., the partial derivative of the loss function with respect to the perturbation variable itself, used to adjust the perturbation direction on a fast time scale to approximate the local maximum loss in the worst case. The fast time-scale update strategy refers to rapidly updating the perturbation vector with a small step size in each training iteration, allowing it to grow along the second gradient direction, thereby approximating the perturbation that maximizes the loss in the neighborhood of the current parameters, reflecting the inner layer optimization process. The slow time-scale update strategy refers to slowly updating the initial network parameters with a larger time step size after the perturbation vector has approximately converged, optimizing the backbone model along the flat direction based on the first gradient, reflecting the guiding role of outer layer optimization on generalization performance. The neurodynamic update equation is a differential or difference equation describing the evolution of the perturbation vector over time. By introducing dynamic constraints (such as damping or stabilizing terms), the evolution trajectory of the perturbation is adjusted, enhancing the stability and convergence of the optimization process. The neurodynamic update equation is expressed as follows:

[0093]

[0094] in, It refers to the perturbation vector during the k-th iteration. It refers to the perturbation vector after the k-th round of fast time-scale updates. This refers to the preset fast timescale learning rate. This refers to the second gradient. This refers to the perturbation vector gradient operator, This refers to the initial network parameters during the k-th iteration. This is the activation function, used to ensure that the perturbation vector is within the preset norm constraint.

[0095] Understandably, the image classification system first randomly samples a batch of industrial image samples and their corresponding category labels from the training set at a preset batch size (e.g., 32 or 64). This batch of samples is then input into the initial image classification model for forward propagation, outputting the predicted probability distribution of each sample across all predefined defect or state categories. This process aims to obtain the current model's judgment criteria for the semantic content of industrial images. Second, the system uses a preset loss function to calculate the loss value between the predicted probability distribution and the true category label, quantifying the model's classification error under the current parameters. Then, the system element-wise adds the initial network parameters to the initial perturbation vector to generate perturbed parameter points, simulating the worst-case perturbation scenario within the parameter neighborhood. Next, based on the aforementioned loss value, the system calculates the gradient of the model at the perturbed parameter points with respect to the network backbone parameters (i.e., the first gradient) and the gradient with respect to the initial perturbation vector (i.e., the second gradient). The former reflects how the main parameters should be updated to reduce the loss in the worst-case scenario, while the latter indicates how the perturbation direction should be adjusted to approximate the local maximum loss. Subsequently, the system employs a fast time-scale update strategy, combining the second gradient with a neurodynamic update equation (e.g., a first-order differential equation with a damping term) to dynamically evolve the perturbation vector at high frequency and small steps, enabling it to quickly converge to the worst perturbation direction within the current parameter neighborhood. Simultaneously, a slow time-scale update strategy is used, utilizing the first gradient to update the initial network parameters at low frequency and large steps, guiding the backbone network towards a flat region of the loss surface. This enhances the model's robustness under the complex conditions inherent in industrial image data, such as noise, blur, and imbalanced samples. Finally, the system repeats the above iterative process several times until training converges, outputting the final reference image classification model. This training process, by explicitly separating the optimization rhythm of perturbation search and parameter learning, allows the algorithm to adapt to the stringent requirements of stability and generalization ability in industrial vision scenarios. It ensures that the model input is labeled images collected from real production lines, and the output is defect or state categories with clear physical meaning, establishing an intrinsic connection between the algorithm mechanism and the industrial image classification task.

[0096] As an example, the step of training the initial image classification model according to the fast timescale update strategy, the second gradient, the neural dynamics update equation, the slow timescale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model includes: updating the initial perturbation vector according to the fast timescale update strategy, combined with the second gradient and the neural dynamics update equation to obtain the updated perturbation vector; performing a projection operation on the updated perturbation vector according to the preset norm constraint to obtain the target perturbation vector; updating the initial network parameters according to the slow timescale update strategy, combined with the first gradient to obtain the updated network parameters; using the updated network parameters and the target perturbation vector as the initial network parameters and the initial perturbation vector for the next iteration, respectively, and returning to the step of selecting a batch of training samples and the corresponding class labels from the training set, inputting them into the initial image classification model for forward propagation to obtain the predicted probability distribution, until the loss value converges or reaches the preset number of training rounds, to obtain the reference image classification model.

[0097] It should be noted that the pre-defined norm constraint refers to the mathematical restriction imposed on the magnitude of the perturbation vector. This is typically achieved using the L2 norm (Euclidean norm) or L∞ norm (infinite norm) to ensure that the magnitude of the perturbation vector does not exceed a pre-defined perturbation radius (e.g., 0.05). This ensures that the perturbation remains within the local neighborhood of the model parameters, preventing the optimization process from deviating from the effective region. The target perturbation vector is the final perturbation vector that satisfies the perturbation magnitude constraint, obtained by projecting the initial perturbation vector according to the pre-defined norm constraint (e.g., scaling the perturbation vector to an L2 sphere with a radius of 0.05). This vector is used to construct the perturbation-adjusted parameter points in the next iteration.

[0098] To ensure that the disturbance vector satisfies the constraints Perform the following projection operation:

[0099]

[0100]

[0101] in, This refers to the initial disturbance vector; the right side of the formula The updated perturbation vector refers to the perturbation vector corresponding to the (k+1)th iteration after the fast timescale update but before the projection operation; the left side of the formula... It refers to the target perturbation vector obtained in the (k+1)th iteration after the projection operation; This refers to the norm type identifier, used to distinguish different norm constraint rules; This refers to the preset disturbance radius; It refers to the L2 norm value of the perturbation vector of the (k+1)th round that has not yet been projected;

[0102] The preset number of training rounds refers to the maximum number of iterations (e.g., 200 times) set in advance for the entire training process. It is used as one of the training termination conditions. When the model has completed the specified number of training rounds or the loss value has converged, the iteration stops and the reference image classification model is output to prevent overfitting and control computational overhead.

[0103] Understandably, firstly, the system substitutes the second gradient into the neural dynamics update equation to update the initial perturbation vector in one step, obtaining the updated perturbation vector. This operation approximates the worst perturbation direction by quickly responding to local changes in the loss surface, thereby enhancing the model's robustness to parameter perturbations. Secondly, the system calculates the L2 norm of the updated perturbation vector. If it is greater than the preset perturbation radius, it is scaled proportionally until the norm is exactly equal to the preset perturbation radius, ensuring that the perturbation is always confined within the parameter neighborhood and avoiding optimization deviations from a reasonable region. Then, the system uses the first gradient, combined with a slow time-scale update strategy (e.g., using the standard SGD or Adam optimizer with a small learning rate such as 0.01), to perform a backbone parameter update on the initial network parameters, generating updated network parameters. This update is slower, aiming to stably guide the model towards a flat minimum region, improving generalization ability. Finally, the system uses the updated network parameters and target perturbation vector as the initial network parameters and initial perturbation vector for the next iteration, respectively. It then resamples a batch of data from the training set and performs forward propagation, repeating the above process until the loss value stabilizes or the number of training rounds reaches the preset number of training rounds. Finally, it outputs the converged model as a reference image classification model.

[0104] As an example, the step of calculating the first gradient of the initial image classification model corresponding to the perturbed parameter point and the second gradient corresponding to the initial perturbed vector based on the loss value includes: calculating the partial derivative of the loss value with respect to the perturbed parameter point based on the backpropagation algorithm to obtain the original gradient; performing gradient clipping on the original gradient to obtain the clipped gradient; using the clipped gradient as the first gradient corresponding to the perturbed parameter point; and calculating the partial derivative of the loss value with respect to the initial perturbed vector to obtain the second gradient corresponding to the initial perturbed vector.

[0105] It should be noted that the original gradient refers to the unprocessed gradient vector obtained by calculating the partial derivatives of the loss value with respect to the network parameters at the perturbed parameter points based on the backpropagation algorithm. It reflects the local direction and rate of change of the loss function with respect to the backbone network parameters at the perturbed parameter positions. The cropped gradient refers to the corrected gradient obtained after cropping the original gradient. It is used to suppress abnormally large gradients caused by industrial image noise or small batch sampling fluctuations, thereby improving the numerical stability of the training process.

[0106] Understandably, the system first uses backpropagation to calculate the partial derivatives of the loss value with respect to all network parameters at the perturbed parameter points, layer by layer, to obtain the original gradient. This process aims to obtain the local optimization direction of the model at the perturbed location. Second, the system performs gradient clipping on the original gradient—specifically, it calculates the L2 norm. If it exceeds a preset threshold (e.g., 1.0), the entire gradient vector is scaled proportionally to a norm of 1.0 to prevent gradient explosion caused by noise in industrial images or small-batch sampling fluctuations, thereby improving training stability. The clipped result is used as the first gradient corresponding to the perturbed parameter points. Finally, the system simultaneously calculates the partial derivatives of the loss value with respect to each component of the initial perturbed vector, directly obtaining the second gradient corresponding to the initial perturbed vector. This second gradient is used to update the perturbed direction on a fast timescale, making it approximate the most unfavorable perturbed situation in the current parameter neighborhood.

[0107] As an example, the step of updating the initial perturbation vector according to the fast timescale update strategy, combining the second gradient and the neurodynamic update equation to obtain the updated perturbation vector includes: determining the activation function in the neurodynamic update equation, wherein the activation function is used to limit the range of values ​​of the perturbation vector; inputting the second gradient into the activation function for nonlinear transformation to obtain the transformed gradient; adding the initial perturbation vector to the transformed gradient according to the neurodynamic update equation to obtain an intermediate perturbation vector; subtracting the initial perturbation vector from the intermediate perturbation vector to obtain the perturbation update increment; multiplying the perturbation update increment by a preset fast timescale learning rate, and then adding it to the initial perturbation vector to obtain the updated perturbation vector.

[0108] It should be noted that the activation function refers to a nonlinear function (such as tanh or sigmoid) introduced into the neural dynamics update equation to map the second gradient, thereby limiting the range of values ​​of the perturbation vector and enhancing its dynamic stability, avoiding excessive perturbation amplitude or divergence. The transformed gradient refers to the nonlinear transformation result output after inputting the second gradient element-wise into the activation function. Its value is compressed into the output range of the activation function (e.g., tanh limits the value to [-1, 1]) to regulate the direction and amplitude of the perturbation update. The intermediate perturbation vector is a temporary vector obtained by directly adding the initial perturbation vector to the transformed gradient. It serves as an intermediate state in the perturbation evolution process and is used to calculate the update increment later. The perturbation update increment is the difference between the intermediate perturbation vector and the initial perturbation vector, which is essentially equal to the transformed gradient. It represents the amount of change that the perturbation should undergo at the current fast timescale step size and participates in the final perturbation update after being multiplied by a preset fast timescale learning rate.

[0109] Understandably, firstly, the training images are input into the initial image classification model, and the prediction results are obtained through forward propagation. The gradient is then calculated using a pre-defined loss function. In the... The network parameters at the next iteration are: The gradient is ,in, It is the gradient operator, used to calculate a vector consisting of the partial derivatives of a function with respect to variables. It refers to the d-dimensional real space. This refers to the network parameters at the t-th iteration. The loss function (general symbol) is the independent variable.

[0110] Calculate the parameter points after the disturbance loss gradient at ,in, This refers to the network parameters at the k-th iteration. This refers to the initial perturbation vector during the k-th iteration. This refers to the loss function (specifically represented). The subscript θ in the text indicates that the gradient applies to θ, where θ refers to the network parameters.

[0111] Secondly, update the model parameters according to the outer optimization rules with a slow time scale. ,in, This refers to the network parameters at the (k+1)th iteration. This refers to the preset slow timescale learning rate.

[0112] Then, calculate the perturbation gradient. The initial perturbation vector is updated according to the fast-timescale neural dynamics update equation.

[0113] As an example, the step of updating the initial network parameters according to the slow timescale update strategy and combining the first gradient to obtain the updated network parameters includes: adjusting the preset slow timescale learning rate using a cosine annealing strategy to obtain a target slow timescale learning rate; multiplying the first gradient by a preset weight decay coefficient to obtain the decayed gradient; calculating the historical gradient accumulation value according to a preset momentum factor, wherein the historical gradient accumulation value refers to the value formed by weighting and accumulating the first gradient calculated in each iteration according to the preset momentum factor in each iteration before the current iteration; adding the decayed gradient to the historical gradient accumulation value to obtain the current gradient accumulation value; multiplying the current gradient accumulation value by the target slow timescale learning rate to obtain the gradient update amount; and subtracting the gradient update amount from the initial network parameters to obtain the updated network parameters.

[0114] It should be noted that cosine annealing is a scheduling method that dynamically adjusts the learning rate, smoothly decreasing it from the initial learning rate to near zero according to a cosine function. The specific formula is as follows:

[0115]

[0116] in, For the current training round, The preset number of training epochs is used to gradually reduce the learning rate in the later stages of training to achieve stable convergence. This refers to a learning rate set for a slow time scale. This refers to the learning rate on the target's slow time scale.

[0117] The preset slow-timescale learning rate refers to the initial value of the base learning rate (e.g., 0.1) pre-set in the slow-timescale update strategy, used to control the step size of the backbone network parameter updates (in this embodiment, the preset fast-timescale learning rate is 0.3, i.e., 3 times the preset slow-timescale learning rate). The target slow-timescale learning rate refers to the actual learning rate used in the current training round after adjusting the preset slow-timescale learning rate through a cosine annealing strategy, which gradually decays as the training progresses. The preset weight decay coefficient refers to the hyperparameter used for L2 regularization (e.g., 0.0005), introducing a penalty term for the size of the network parameters in gradient calculation to suppress overfitting. The decayed gradient refers to the regularization term obtained by multiplying the first gradient by the preset weight decay coefficient. The gradient actually involved in parameter updates includes the sum of this decay term and the original loss gradient, but in this context, it specifically refers to this regularization part. The preset momentum factor refers to the historical gradient weighting coefficient (e.g., 0.9) used in the momentum optimization algorithm to retain information about the direction of previous gradients during updates, accelerating convergence and reducing oscillations. The current gradient accumulation value refers to the combined gradient obtained by adding the decayed gradient to the historical gradient accumulation value weighted according to the preset momentum factor. It represents the effective gradient direction used for parameter update in the current iteration step. The gradient update amount refers to the parameter adjustment magnitude obtained by multiplying the current gradient accumulation value by the target slow time scale learning rate. It is used to subtract from the initial network parameters to complete one update of the backbone network parameters.

[0118] Experimental data and related explanations for this embodiment:

[0119] (1) Prepare standard image classification datasets for training. The datasets used include three representative datasets: CIFAR (Canadian Institute for Advanced Research) and Fashion-MNIST (Fashion Modified National Institute of Standards and Technology). Among them, the CIFAR dataset is divided into two versions: CIFAR-10 and CIFAR-100. CIFAR-10 contains 60,000 color images with a size of 32×32, divided into 10 categories, with 6,000 images in each category; CIFAR-100 is divided into 100 categories, with 600 images in each category. The Fashion-MNIST dataset contains 70,000 grayscale images with a size of 28×28, divided into 10 clothing categories. The training set contains 60,000 images, and the test set contains 10,000 images. It is a modern alternative to the traditional MNIST dataset and is widely used to evaluate the performance of image classification algorithms. The aforementioned datasets cover different categories, image sizes, and image complexities, and can be effectively used to evaluate the optimization performance and generalization ability of this application in various image classification tasks.

[0120] (2) Define the loss function during network training. The loss function used in this embodiment is the cross-entropy loss function, which is used to measure the difference between the model's predicted class distribution and the true label distribution, and to guide the iterative optimization process of neural network parameters.

[0121] (3) Selecting a neural network structure. In this embodiment, four classic deep neural networks are selected as training models: ResNet-18 (Residual Network with 18 Layers), MobileNet-V1 (Mobile Network Version 1), DenseNet-121 (Densely Connected Convolutional Network with 121 Layers), and WRN-28-10 (Wide Residual Network with Depth 28 and Widening factor 10).

[0122] (4) Execute the training process of the neural network. In each round of training iteration, the training samples and corresponding target labels are input into the network. Forward propagation is performed to calculate the predicted output, the loss value is calculated based on the defined loss function, and the gradient is calculated using the backpropagation algorithm. Subsequently, the network parameters are updated according to the optimization algorithm. The above steps are repeated until the number of training rounds reaches the preset value or the conditions for stopping training are met.

[0123] (5) Experimental verification;

[0124] To verify the effectiveness of the optimization method described in this application in improving the generalization ability of deep neural networks, comparative experiments were designed and its performance was evaluated against existing mainstream optimization algorithms. Specifically, Momentum Stochastic Gradient Descent (SGD-M) and Sharpness-Aware Minimization (SAM) were selected as benchmark optimization algorithms, and experimental comparisons were conducted in several typical task scenarios. The number of training rounds was set to 200, and the batch size was set to 256. All experiments used a labeled smoothed cross-entropy loss function, with the momentum factor set to 0.9 and the weight decay coefficient set to 0.0005. Regarding the learning rate strategy, a cosine annealing strategy was used to adjust the learning rate for the training task, with an initial learning rate of 0.1. For SAM and the Cooperative Neurodynamic Sharpness-Aware Minimization (CNSAM) optimization method proposed in this application, the perturbation radius parameter was set to... All are set to 0.05. In BLOSAM, the fast and slow scale ratio is set to... To ensure the reproducibility of experimental results, all experiments were initialized using a fixed random seed.

[0125] Table 1

[0126]

[0127] Table 1 shows the results on the Fashion-MNIST dataset, validating the effectiveness of the proposed Blend-Based Sharpness-Aware Minimization (BLOSAM) method. For all network model architectures, the models trained using the proposed BLOSAM method outperformed the SAM and SGD-M methods in both test loss and test accuracy. These experimental results demonstrate that BLOSAM not only possesses superior optimization performance but also achieves higher accuracy while maintaining lower loss, validating its excellent generalization ability in image classification tasks.

[0128] Table 2

[0129]

[0130] Table 2 shows that the model trained using the BLOSAM method proposed in this application achieves the lowest test loss across all architectures on the CIFAR-10 dataset, and comprehensively outperforms the SAM and SGD-M methods in test accuracy. These experimental results further demonstrate the good adaptability and robustness of the optimized method in this application across different network depths, particularly its significantly superior generalization error control capability during training compared to existing techniques.

[0131] Table 3

[0132]

[0133] Table 3 shows the results on the CIFAR-100 dataset. As can be seen from the table, across all model architectures, the model trained using the BLOSAM method described in this application achieves the best results in both test loss and test accuracy. In summary, the optimized method in this application demonstrates stronger generalization ability and stability in handling challenging multi-class classification tasks like CIFAR-100, proving its broad adaptability and advanced nature in complex deep neural network task scenarios.

[0134] This embodiment first selects a batch of training samples and their corresponding class labels from the training set, inputs them into the initial image classification model for forward propagation, and obtains the predicted probability distribution, thereby obtaining the model's classification output for the current industrial image. Second, it calculates the loss value between the predicted probability distribution and the true class label according to a preset loss function, providing a quantization error signal for parameter updates. Next, it adds the initial network parameters to the initial perturbation vector to construct perturbed parameter points, modeling the potential worst-case perturbation scenario within the parameter neighborhood. Then, based on this loss value, it calculates the first gradient of the model at the perturbed parameter points with respect to the network backbone parameters and the second gradient with respect to the initial perturbation vector, achieving independent perception of the principal parameters and the perturbation direction. Finally, it updates the perturbation vector by combining a fast timescale update strategy, the second gradient, and the neurodynamic update equation, while simultaneously updating the network backbone parameters according to a slow timescale update strategy and the first gradient. Through a dual-timescale collaborative mechanism, it completes model training and obtains a reference image classification model. This process effectively decouples the perturbation generation and parameter learning processes, improving training stability and model generalization ability.

[0135] For example, to help understand the implementation process of the image classification method based on a two-layer optimized neural network obtained by combining this embodiment with the above embodiment one, please refer to... Figure 3 , Figure 3 A simplified flowchart of an image classification method based on a two-layer optimized neural network is provided, specifically:

[0136] The process begins by acquiring raw image data containing blur, noise, and other interference, along with their corresponding labels. This data is then standardized and preprocessed to eliminate the effects of uneven lighting and scale differences, improving the consistency and quality of the input data. The preprocessed data is then used as training data and fed into the neural network for forward propagation, yielding the model's predicted output for the image. Next, the system updates the network parameters using a sharpness-aware minimization method based on two-layer optimization and neurodynamics. This process enhances the model's generalization ability by searching for the worst-case perturbation direction within the parameter neighborhood and guiding the backbone parameters to converge towards a flat minimum region. Backpropagation is then performed to calculate the loss gradient and update the parameters. The system then checks if the convergence condition or the maximum number of training epochs is met. If not, it returns to the forward propagation step to continue iterative training; if the condition is met, training is complete, forming a trained classification network. Finally, in practical applications, the image to be classified is input into this trained network, and after forward propagation, the final classification result is output, achieving stable and accurate discrimination of complex images in industrial scenarios. The entire process clearly demonstrates a complete closed loop from data preparation and model training to actual deployment, highlighting the key role of the two-layer optimization mechanism in improving model robustness and generalization performance.

[0137] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the image classification method based on the two-layer optimized neural network of this application. Any simple modifications based on this technical concept are within the protection scope of this application.

[0138] This application also provides an image classification device based on a two-layer optimized neural network. Please refer to [link / reference]. Figure 4 The image classification device based on a two-layer optimized neural network includes:

[0139] Data preprocessing module 10 is used to preprocess historical industrial image data to obtain training set and validation set, both of which contain corresponding category labels;

[0140] The model building module 20 is used to build an initial image classification model based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector.

[0141] The model training module 30 is used to train the initial image classification model based on the training set according to the bi-layer optimization and neurodynamic mechanism to obtain a reference image classification model.

[0142] Model validation module 40 is used to evaluate the performance and adjust the parameters of the reference image classification model based on the validation set to obtain an industrial image classification model;

[0143] The image classification module 50 is used to input newly added industrial images into the industrial image classification model to obtain classification results.

[0144] The image classification device based on a two-layer optimized neural network provided in this application, employing the image classification method based on a two-layer optimized neural network in the above embodiments, can solve the technical problem of how to alleviate the coupling problem between perturbation and parameter update during deep neural network training in industrial image classification tasks, reduce sensitivity to hyperparameters, and improve the generalization ability and stability of the model under complex working conditions. Compared with the prior art, the beneficial effects of the image classification device based on a two-layer optimized neural network provided in this application are the same as those of the image classification method based on a two-layer optimized neural network provided in the above embodiments, and other technical features in the image classification device based on a two-layer optimized neural network are the same as those disclosed in the methods of the above embodiments, and will not be repeated here.

[0145] This application provides an image classification device based on a two-layer optimized neural network. The image classification device based on a two-layer optimized neural network includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor to enable the at least one processor to perform the image classification method based on a two-layer optimized neural network in the above embodiment 1.

[0146] The following is for reference. Figure 5 This document illustrates a structural schematic diagram of an image classification device based on a two-layer optimized neural network, suitable for implementing embodiments of this application. The image classification device based on a two-layer optimized neural network in the embodiments of this application may include, but is not limited to, mobile terminals such as mobile phones, laptops, digital broadcast receivers, PDAs (Personal Digital Assistants), PADs (Portable Application Description), PMPs (Portable Media Players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The image classification device based on a two-layer optimized neural network shown is merely an example and should not impose any limitations on the functionality and scope of use of the embodiments of this application.

[0147] like Figure 5As shown, the image classification device based on a two-layer optimized neural network may include a processing unit 1001 (e.g., a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to a program stored in ROM (Read Only Memory) 1002 or a program loaded from storage device 1003 into RAM (Random Access Memory) 1004. RAM 1004 also stores various programs and data required for the operation of the image classification device based on the two-layer optimized neural network. The processing unit 1001, ROM 1002, and RAM 1004 are interconnected via bus 1005. Input / output (I / O) interface 1006 is also connected to the bus. Typically, the following systems can be connected to I / O interface 1006: input devices 1007 including, for example, touchscreens, touchpads, keyboards, mice, image sensors, microphones, accelerometers, gyroscopes, etc.; output devices 1008 including, for example, LCDs (Liquid Crystal Displays), speakers, vibrators, etc.; storage devices 1003 including, for example, magnetic tapes, hard disks, etc.; and communication devices 1009. Communication device 1009 allows the image classification device based on a two-layer optimized neural network to communicate wirelessly or wiredly with other devices to exchange data. Although the figure shows an image classification device based on a two-layer optimized neural network with various systems, it should be understood that it is not required to implement or possess all the systems shown. More or fewer systems can be implemented alternatively.

[0148] Specifically, according to the embodiments disclosed in this application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, embodiments disclosed in this application include a computer program product comprising a computer program carried on a computer-readable medium, the computer program containing program code for performing the methods shown in the flowcharts. In such embodiments, the computer program can be downloaded and installed from a network via a communication device, or installed from storage device 1003, or installed from ROM 1002. When the computer program is executed by processing device 1001, it performs the functions defined in the methods of the embodiments disclosed in this application.

[0149] The image classification device based on a two-layer optimized neural network provided in this application, employing the image classification method based on a two-layer optimized neural network in the above embodiments, can solve the technical problem of how to alleviate the coupling problem between perturbation and parameter update during deep neural network training in industrial image classification tasks, reduce sensitivity to hyperparameters, and improve the generalization ability and stability of the model under complex working conditions. Compared with the prior art, the beneficial effects of the image classification device based on a two-layer optimized neural network provided in this application are the same as those of the image classification method based on a two-layer optimized neural network provided in the above embodiments, and other technical features in this image classification device based on a two-layer optimized neural network are the same as those disclosed in the previous embodiment method, and will not be repeated here.

[0150] It should be understood that the various parts disclosed in this application can be implemented using hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in any suitable manner in one or more embodiments or examples.

[0151] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.

[0152] This application provides a computer-readable storage medium having computer-readable program instructions (i.e., a computer program) stored thereon, the computer-readable program instructions being used to execute the image classification method based on a two-layer optimized neural network in the above embodiments.

[0153] The computer-readable storage medium provided in this application may be, for example, a USB flash drive, but is not limited to, electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or any combination thereof. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections having one or more wires, portable computer disks, hard disks, RAM (Random Access Memory), ROM (Read Only Memory), EPROM (Erasable Programmable Read Only Memory or Flash Memory), optical fibers, CD-ROM (CD-Read Only Memory), optical storage devices, magnetic storage devices, or any suitable combination thereof. In this embodiment, the computer-readable storage medium may be any tangible medium containing or storing a program that can be used by or in conjunction with an instruction execution system, system, or device. The program code contained on the computer-readable storage medium may be transmitted using any suitable medium, including but not limited to: wires, optical cables, RF (Radio Frequency), etc., or any suitable combination thereof.

[0154] The aforementioned computer-readable storage medium may be included in an image classification device based on a two-layer optimized neural network; or it may exist independently and not be assembled into an image classification device based on a two-layer optimized neural network.

[0155] The aforementioned computer-readable storage medium carries one or more programs. When these programs are executed by an image classification device based on a two-layer optimized neural network, the image classification device performs the following actions: preprocesses historical industrial image data to obtain a training set and a validation set, both of which contain corresponding category labels; constructs an initial image classification model based on the target neural network structure, a preset loss function, initial network parameters, and an initial perturbation vector; trains the initial image classification model using the training set based on a two-layer optimization and neurodynamics mechanism to obtain a reference image classification model; evaluates the performance and adjusts the parameters of the reference image classification model using the validation set to obtain an industrial image classification model; and inputs newly added industrial images into the industrial image classification model to obtain classification results.

[0156] Computer program code for performing the operations of this application can be written in one or more programming languages ​​or a combination thereof, including object-oriented programming languages ​​such as Java, Smalltalk, and C++, as well as conventional procedural programming languages ​​such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, as a standalone software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In cases involving remote computers, the remote computer can be connected to the user's computer via any type of network—including LAN (Local Area Network) or WAN (Wide Area Network)—or can be connected to an external computer (e.g., via the Internet using an Internet service provider).

[0157] The flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of systems, methods, and computer program products according to various embodiments of this application. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions indicated in the blocks may occur in a different order than those indicated in the drawings. For example, two consecutively indicated blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagrams and / or flowcharts, and combinations of blocks in the block diagrams and / or flowcharts, can be implemented using a dedicated hardware-based system that performs the specified function or operation, or using a combination of dedicated hardware and computer instructions.

[0158] The modules described in the embodiments of this application can be implemented in software or hardware. The names of the modules do not necessarily limit the functionality of the unit itself.

[0159] The readable storage medium provided in this application is a computer-readable storage medium that stores computer-readable program instructions (i.e., a computer program) for executing the above-described image classification method based on a two-layer optimized neural network. This addresses the technical problem of mitigating the coupling between perturbations and parameter updates during deep neural network training in industrial image classification tasks, reducing sensitivity to hyperparameters, and improving the model's generalization ability and stability under complex conditions. Compared with existing technologies, the beneficial effects of the computer-readable storage medium provided in this application are the same as those of the image classification method based on a two-layer optimized neural network provided in the above embodiments, and will not be elaborated upon here.

[0160] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the steps of the image classification method based on a two-layer optimized neural network as described above.

[0161] The computer program product provided in this application can solve the technical problem of mitigating the coupling problem between perturbation and parameter update during deep neural network training in industrial image classification tasks, reducing sensitivity to hyperparameters, and improving the generalization ability and stability of the model under complex working conditions. Compared with the prior art, the beneficial effects of the computer program product provided in this application are the same as those of the image classification method based on a two-layer optimized neural network provided in the above embodiments, and will not be repeated here.

[0162] The above description is only a part of the embodiments of this application and does not limit the patent scope of this application. All equivalent structural transformations made under the technical concept of this application and using the contents of the specification and drawings of this application, or direct / indirect applications in other related technical fields, are included in the patent protection scope of this application.

Claims

1. An image classification method based on a two-layer optimized neural network, characterized in that, The method includes: Historical industrial image data is preprocessed to obtain a training set and a validation set, both of which contain corresponding category labels. Based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector, construct an initial image classification model; Based on the bi-layer optimization and neurodynamics mechanism, the initial image classification model is trained according to the training set to obtain the reference image classification model; Based on the validation set, the performance of the reference image classification model is evaluated and the parameters are adjusted to obtain the industrial image classification model. The newly added industrial images are input into the industrial image classification model to obtain the classification results; The step of training the initial image classification model based on the training set to obtain the reference image classification model, based on the bi-layer optimization and neurodynamics mechanism, includes: A batch of training samples and their corresponding category labels are selected from the training set and input into the initial image classification model for forward propagation to obtain the predicted probability distribution. Calculate the loss value between the predicted probability distribution and the category label based on the preset loss function; Add the initial network parameters to the initial perturbation vector to obtain the perturbed parameter points; Based on the loss value, calculate the first gradient of the initial image classification model corresponding to the parameter points after the perturbation and the second gradient corresponding to the initial perturbation vector; The initial image classification model is trained based on the fast timescale update strategy, the second gradient, the neural dynamics update equation, the slow timescale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model. The step of training the initial image classification model according to the fast time-scale update strategy, the second gradient, the neural dynamics update equation, the slow time-scale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model includes: The initial perturbation vector is updated according to the fast timescale update strategy, combined with the second gradient and the neural dynamics update equation, to obtain the updated perturbation vector; Based on the preset norm constraint, the updated perturbation vector is projected to obtain the target perturbation vector; The updated network parameters are obtained by updating the initial network parameters according to the slow time scale update strategy and the first gradient. The updated network parameters and the target perturbation vector are used as the initial network parameters and the initial perturbation vector for the next iteration, respectively. The steps of selecting a batch of training samples and the corresponding category labels from the training set and inputting them into the initial image classification model for forward propagation to obtain the predicted probability distribution are repeated until the loss value converges or reaches the preset number of training rounds to obtain the reference image classification model. The neurodynamic update equation is expressed as follows: in, It refers to the perturbation vector during the k-th iteration. It refers to the perturbation vector after the k-th round of fast time-scale updates. This refers to a preset learning rate over a fast time scale. This refers to the second gradient. This refers to the perturbation vector gradient operator, This refers to the initial network parameters during the k-th iteration. This is the activation function, used to ensure that the perturbation vector is within the preset norm constraint.

2. The method as described in claim 1, characterized in that, The step of calculating the first gradient of the initial image classification model corresponding to the parameter points after the perturbation and the second gradient corresponding to the initial perturbation vector based on the loss value includes: Based on the backpropagation algorithm, the partial derivative of the loss value with respect to the perturbed parameter points is calculated to obtain the original gradient; The original gradient is subjected to gradient clipping to obtain the clipped gradient; The clipped gradient is used as the first gradient corresponding to the perturbated parameter point; Calculate the partial derivative of the loss value with respect to the initial perturbation vector to obtain the second gradient corresponding to the initial perturbation vector.

3. The method as described in claim 1, characterized in that, The step of updating the initial perturbation vector according to the fast time-scale update strategy, combined with the second gradient and the neural dynamics update equation, to obtain the updated perturbation vector includes: Determine the activation function in the neurodynamic update equation, wherein the activation function is used to limit the range of values ​​of the perturbation vector; The second gradient is input into the activation function for nonlinear transformation to obtain the transformed gradient; According to the neural dynamics update equation, the initial perturbation vector is added to the transformed gradient to obtain the intermediate perturbation vector; Subtracting the initial perturbation vector from the intermediate perturbation vector yields the perturbation update increment; The perturbation update increment is multiplied by a preset fast timescale learning rate, and then added to the initial perturbation vector to obtain the updated perturbation vector.

4. The method as described in claim 1, characterized in that, The step of updating the initial network parameters according to the slow time-scale update strategy and combining the first gradient to obtain the updated network parameters includes: The cosine annealing strategy is used to adjust the preset slow time scale learning rate to obtain the target slow time scale learning rate. Multiply the first gradient by the preset weight decay coefficient to obtain the decayed gradient; Based on a preset momentum factor, the historical gradient cumulative value is calculated. The historical gradient cumulative value refers to the value formed by weighting and accumulating the first gradient calculated in each iteration according to the preset momentum factor in each iteration before the current iteration. The current gradient accumulation value is obtained by adding the decayed gradient to the historical gradient accumulation value. Multiply the current accumulated gradient value by the target slow timescale learning rate to obtain the gradient update amount; The updated network parameters are obtained by subtracting the gradient update amount from the initial network parameters.

5. An image classification device based on a two-layer optimized neural network, characterized in that, The device includes: The data preprocessing module is used to preprocess historical industrial image data to obtain a training set and a validation set, both of which contain corresponding category labels. The model building module is used to build an initial image classification model based on the target neural network structure, the preset loss function, the initial network parameters, and the initial perturbation vector. The model training module is used to train the initial image classification model based on the training set using a two-layer optimization and neurodynamics mechanism to obtain a reference image classification model. The steps of training the initial image classification model based on the training set to obtain the reference image classification model include: selecting a batch of training samples and corresponding category labels from the training set, inputting them into the initial image classification model for forward propagation to obtain a predicted probability distribution; calculating the loss value between the predicted probability distribution and the category labels according to a preset loss function; adding the initial network parameters to the initial perturbation vector to obtain perturbed parameter points; calculating the first gradient of the initial image classification model corresponding to the perturbed parameter points and the second gradient corresponding to the initial perturbation vector based on the loss value; and training the initial image classification model according to a fast timescale update strategy, the second gradient, a neurodynamic update equation, a slow timescale update strategy, the first gradient, and the initial network parameters to obtain the reference image classification model. The steps for training the initial image classification model to obtain a reference image classification model based on the fast time-scale update strategy, the second gradient, the neurodynamic update equation, the slow time-scale update strategy, the first gradient, and the initial network parameters include: updating the initial perturbation vector according to the fast time-scale update strategy, combined with the second gradient and the neurodynamic update equation, to obtain the updated perturbation vector; performing a projection operation on the updated perturbation vector according to a preset norm constraint to obtain the target perturbation vector; updating the initial network parameters according to the slow time-scale update strategy, combined with the first gradient, to obtain the updated network parameters; using the updated network parameters and the target perturbation vector as the initial network parameters and initial perturbation vector for the next iteration, respectively, and returning to the step of selecting a batch of training samples and the corresponding category labels from the training set, inputting them into the initial image classification model for forward propagation to obtain the predicted probability distribution, until the loss value converges or reaches a preset number of training rounds, to obtain the reference image classification model; the neurodynamic update equation is expressed as follows: in, It refers to the perturbation vector during the k-th iteration. It refers to the perturbation vector after the k-th round of fast time-scale updates. This refers to a preset learning rate over a fast time scale. This refers to the second gradient. This refers to the perturbation vector gradient operator, This refers to the initial network parameters during the k-th iteration. This is the activation function, used to ensure that the perturbation vector is within the preset norm constraint; The model validation module is used to evaluate the performance and adjust the parameters of the reference image classification model based on the validation set to obtain an industrial image classification model. The image classification module is used to input newly added industrial images into the industrial image classification model to obtain classification results.

6. An image classification device based on a two-layer optimized neural network, characterized in that, The device includes: a memory, a processor, and a computer program stored in the memory and executable on the processor, the computer program being configured to implement the steps of the image classification method based on a two-layer optimized neural network as described in any one of claims 1 to 4.

7. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium. When the computer program is executed by a processor, it implements the steps of the image classification method based on a two-layer optimized neural network as described in any one of claims 1 to 4.