Inference-based efficient dynamic optimization models, methods, systems, and devices for early termination.

By adopting a multi-stage early termination network architecture and a dynamic loss weight adjustment strategy, the problem of decoupling between shallow and deep capabilities in early termination networks is solved, improving the model's inference efficiency and classification accuracy, and achieving a balance between training and inference efficiency.

CN119721254BActive Publication Date: 2025-10-31TIANJIN UNIV
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202411921894.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-12-25
Publication Date
2025-10-31
Estimated Expiration
2044-12-25

AI Technical Summary

Technical Problem

In early termination networks, shallow layers cannot effectively decouple low-level expressive power from high-level discriminative power, leading to a decrease in model performance during inference.

Method used

A multi-stage early termination network architecture is adopted, with lightweight side-branch modules and classifiers inserted in each stage. Combined with residual connections, a high-order classifier and dynamic loss weight adjustment strategy are used to optimize the training process to balance the feature representation and discrimination capabilities of shallow and deep layers.

Benefits of technology

It achieves improved inference efficiency and classification accuracy of the model while maintaining training efficiency, solves the problem of decoupling shallow and deep capabilities, and enhances the model's generalization ability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119721254B_ABST
    Figure CN119721254B_ABST
Patent Text Reader

Abstract

This invention discloses a dynamic optimization model, method, system, and device based on inference-efficient early termination: Based on an early termination network, a side branch module is inserted into each stage's classification branch and residual connections are made. The output features of each stage are processed by the corresponding side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input to the corresponding classifier. The output of each classifier is multiplied by a confidence factor, then processed by a softmax function to obtain the predicted classification probability value, and then cross-entropy is calculated with the corresponding label of the input image to obtain the loss for each stage. The loss of the previous stage is used as a dynamic adjustment parameter and multiplied with the loss of the current stage to obtain the dynamically adjusted loss for the current stage. The weighted sum of the dynamically adjusted losses of all stages is used to obtain the final total loss, which is then used to train the model. The trained model is then used to perform inference classification on the input image.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to neural networks, image recognition technology, and inference-efficient technology. More specifically, it relates to a dynamic optimization model, method, system, and device based on inference-efficient technology for early termination. Background Technology

[0002] In recent years, large-scale deep neural networks have achieved excellent performance in the field of vision. To fully utilize the performance of these networks, the method of pre-training them on large datasets and then fine-tuning them on downstream datasets has been widely used. However, as the network size increases, the computational cost of full fine-tuning the model on downstream datasets becomes increasingly high. Therefore, parameter-efficient methods have become the focus of much research in order to reduce the number of parameters for model fine-tuning and thus reduce the computational cost of the model. These methods freeze the backbone network and only train the parameters of the inserted fine-tuning modules and the linear classifier, which not only makes full use of the knowledge of the original dataset, but also realizes knowledge transfer and saves a lot of computational cost in the fine-tuning process. However, parameter-efficient methods maintain or increase the original inference time of the model. Although they reduce the computational cost of training, they do not significantly improve the inference efficiency of the model.

[0003] In practical applications, computational resources are often scarce, and as network size continues to increase, the issue of model inference efficiency becomes increasingly important. Therefore, many efficient inference methods have been proposed. These include further reducing the model's inference time and improving inference efficiency while maintaining a relatively small number of fine-tuned parameters. These methods often involve redesigning the network and reducing the computation required for samples during the inference phase, achieving improved inference efficiency without significantly altering inference performance.

[0004] Most current efficient inference methods take into account the strong spatial redundancy of sample information in the visual domain, and prune and discard some redundant tokens contained in intermediate features. These methods have the potential problem of information loss, which affects the final performance and generalization ability of the model. In addition, these methods have high network design complexity and require additional design of the network.

[0005] Early retirement networks, combined with efficient parameter fine-tuning methods, divide the network into different stages and set classification heads at different stages, thereby achieving sample-level inference efficiency. Enhancing the discriminative ability of shallow layers is crucial for early retirement networks to maintain good image classification accuracy under incomplete inference. However, in traditional networks, shallow layers are mainly responsible for providing basic representational features to deeper layers. Decoupling the low-level representational ability and high-level discriminative ability of shallow layers in early retirement networks remains a problem that many existing techniques have not solved. Specifically, to achieve early retirement, shallow classifiers need to learn to classify samples, inevitably enhancing their discriminative ability. This leads to excessive discriminative information mixed in with the features input from shallow layers to deeper layers, affecting the learning of deeper layers. This results in a contradiction in early retirement networks: shallow and deep layers cannot simultaneously possess good classification abilities, and shallow layers cannot balance low-level representational ability with high-level discriminative ability. Summary of the Invention

[0006] To address the problem that shallow early termination networks cannot decouple low-level expressive power from high-level discriminative power, this invention proposes a reasoning-based, dynamically optimized early termination model, method, system, and device.

[0007] The objective of this invention can be achieved through the following technical solutions.

[0008] An efficient dynamic optimization early termination model based on inference is proposed. It employs an early termination network consisting of S stages, where the output of the previous stage serves as the input of the next stage. Each stage's classification branch is equipped with a classifier, and lightweight side-branch modules are inserted into each stage's classification branch and residually connected. The output of each stage serves as the input of the corresponding side-branch module in its classification branch. The output of each stage and the output of its corresponding side-branch module are residually connected to obtain classification features, which serve as the input of the classifier in the corresponding classification branch.

[0009] Furthermore, the backbone network of each stage is a ViT network, and the fine-tuning modules used are either LoRA modules or Adapter modules.

[0010] Furthermore, shallow classifiers use higher-order classifiers, while deep classifiers use linear classifiers.

[0011] Furthermore, each of the side branch modules adopts a LoRA module or an Adapter module; in each classification branch, the output features of the corresponding stage are processed by the side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier.

[0012] A dynamic optimization method for an efficient inference-based early termination model includes the following steps:

[0013] S1: The input image is processed sequentially through each stage of the reasoning-based efficient dynamic optimization early termination model, and the output features of each stage are input into its corresponding classification branch and the next stage.

[0014] S2: In each classification branch, the output features of each stage are processed by the corresponding side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier.

[0015] S3: In each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss at each stage;

[0016] S4: In each classification branch, the loss from the previous stage is multiplied by the loss in the current stage as a dynamic adjustment parameter to obtain the dynamically adjusted loss for the current stage.

[0017] S5: Sum the weighted losses after all stages of dynamic adjustment to obtain the final total loss, and use this total loss to train the inference-based, efficient dynamic optimization early termination model;

[0018] S6: Use a trained, reasoning-based, efficient, dynamically optimized early termination model to perform reasoning classification on the input image.

[0019] Furthermore, the dynamically adjusted loss described in step S4 is calculated using the following formula:

[0020]

[0021] Among them, l i This represents the loss in stage i. Let σ represent the loss after dynamic adjustment in stage i, and let σ represent the sigmoid activation function.

[0022] Furthermore, the total loss mentioned in step S5 is obtained according to the following formula:

[0023]

[0024] in, α represents the total loss. i This represents the dynamic loss weight for the i-th stage. In the early stages of training, the dynamic loss weight of the shallow layer is less than that of the deep layer, while in the later stages of training, the dynamic loss weight of the shallow layer is greater than that of the deep layer.

[0025] A reasoning-based, efficient, dynamically optimized early termination system, including...

[0026] The input module is used to input images into the established model.

[0027] A construction module is used to build an efficient dynamic optimization early termination model based on inference. The model adopts an early termination network and consists of S stages, where the output of the previous stage is used as the input of the next stage. Each stage's classification branch is equipped with a classifier, and each stage's classification branch inserts a lightweight side branch module and performs residual connections. The output of each stage is used as the input of the corresponding side branch module in its classification branch. The output of each stage and the output of its corresponding side branch module are residually connected to obtain the classification features, which are used as the input of the classifier in the corresponding classification branch.

[0028] The training module is used to train the established inference-based efficient dynamic optimization early termination model. During training, in each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss of each stage. In each classification branch, the loss of the previous stage is used as a dynamic adjustment parameter and multiplied with the loss of the current stage to obtain the dynamically adjusted loss of the current stage. The weighted sum of the dynamically adjusted losses of all stages is used to obtain the final total loss, which is used to train the inference-based efficient dynamic optimization early termination model.

[0029] The prediction module is used to perform inference classification on the input image using a trained, inference-based, efficient, dynamically optimized early termination model.

[0030] An electronic device includes a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the dynamic optimization method for the reasoning-based efficient dynamic optimization early termination model described above.

[0031] A computer-readable storage medium having a computer program stored thereon, which, when executed by a processor, implements the above-described dynamic optimization method for an efficient dynamic optimization early termination model based on reasoning.

[0032] Compared with existing technologies, this invention addresses the problem that shallow layers in early termination networks cannot decouple low-level expressive power from high-level discriminative power. It improves upon these technologies from the perspectives of model architecture and optimization strategies. The specific technical solutions bring the following beneficial effects:

[0033] (1) From the perspective of architectural improvement. To decouple expressive and discriminative capabilities, from the perspective of network architecture, it is possible to directly manipulate the features input from shallow layers to deep layers, achieving direct decoupling at the feature level. Based on the early regression network, in order to balance the ability of shallow stages to learn low-level expressive features and high-level discriminative features, a side branch module is inserted into the classification branch of each stage. The expressive ability of features transmitted from shallow to deep layers is maintained through residual connections, and the shallow classifier is replaced with a high-order classifier, thus forming a multi-classifier architecture. Compared with existing technologies, this aims to achieve a solution that combines efficient training and efficient inference.

[0034] (2) Dynamic Optimization Strategy Improvement. After completing the architecture improvement, how to train the network is also a key issue. Through targeted improvements, the training strategy can be made more in line with the design of the early retirement network. The core point of the dynamic optimization strategy is to dynamically adjust the loss weight allocation. Throughout the training process, the dynamic loss weight of the shallow layers is smaller in the early stage of training and larger in the later stage, while the dynamic loss weight of the deep layers is larger in the early stage of training and smaller in the later stage. In addition, a learnable confidence factor is introduced and multiplied with the classifier output to enhance the credibility of the shallow layers for the classification results, further improving the reliability of the classification effect. In order to prevent the shallow layers from affecting the deep layers while learning the discriminative ability, the loss of the shallow layers is used as a dynamic adjustment parameter to control the loss of the deep layers, thereby realizing the dynamic adjustment of the deep layer update situation in the later stage of training.

[0035] Compared with existing technologies, this invention utilizes a multi-classifier architecture and dynamic optimization strategies to achieve a combination of efficient training and efficient inference. This invention solves the problem in early regression networks where shallow layers cannot decouple low-level expressive power from high-level discriminative power. Attached Figure Description

[0036] Figure 1 This is a diagram of the dynamic optimization early termination model architecture based on reasoning efficiency of the present invention.

[0037] Figure 2 This is a schematic diagram of the dynamic optimization process of the reasoning-based efficient dynamic optimization early termination model of the present invention. Detailed Implementation

[0038] The present invention will now be further described with reference to the accompanying drawings.

[0039] like Figure 1As shown, this invention proposes a dynamic optimization early termination model based on inference efficiency. It adopts an early termination network consisting of S stages, where the output of the previous stage serves as the input of the next stage. Each stage's classification branch is equipped with a classifier, and each stage's classification branch inserts a lightweight side branch module and performs residual connections. The output of each stage serves as the input of the corresponding side branch module in its classification branch. The output of each stage and the output of its corresponding side branch module are residually connected to obtain classification features, which serve as the input of the classifier in the corresponding classification branch.

[0040] In the above model, the backbone network of each stage is a ViT network, and the fine-tuning modules used are either LoRA modules or Adapter modules.

[0041] In the above model, shallow classifiers can be high-order classifiers, while deep classifiers can be linear classifiers. Note that "deep" and "shallow" are relative terms; for example, stage S-1 can be considered shallow relative to stage S.

[0042] In the above model, each of the side branch modules adopts the same architecture as the fine-tuning module, and both employ either a LoRA module or an Adapter module. In each classification branch, the output features of the corresponding stage are processed by the side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier.

[0043] The above-mentioned dynamic optimization method for the inference-efficient dynamic optimization early termination model, such as... Figure 2 As shown, the specific steps include:

[0044] S1: The input image is processed sequentially through each stage of the reasoning-based efficient dynamic optimization early termination model. The output features of each stage are input into its corresponding classification branch and the next stage.

[0045] S2: In each classification branch, the output features of each stage are processed by the corresponding side branch module and then residually connected with the output features of the corresponding stage to maintain the expressive power of the features passed from shallow to deep layers, thereby obtaining new classification features for each stage, which are then input into the corresponding classifier.

[0046]

[0047] in, BYP represents the classification feature obtained after residual connection in the classification branch of the i-th stage. i X represents the side branch module inserted in the classification branch of the i-th stage. i This represents the output feature of the i-th stage.

[0048] Because LoRA has far fewer parameters than network blocks, inserting a side branch module into the classification branch at each stage adds almost no parameters, yet it encapsulates high-level discriminative information of features. Low-level representational features are transformed into features with high-level discriminative information by the side branch modules. Residual connections preserve the low-level information of the input features, preventing the side branch model from directly destroying the features. This achieves the encapsulation of high-level discriminative information of features while inputting low-level representational information into deeper layers.

[0049] Although the discriminative power of features is enhanced by side-branch modules, classifying complex samples remains challenging. Meanwhile, higher-order classifiers have the potential to improve the performance of shallow network architectures. Inspired by this, and considering the high similarity between shallow layers and shallow network architectures in early-retreat networks, a higher-order classifier is introduced into the shallow layers. The higher-order classifier reduces the impact of the low-level feature representation capabilities of the shallow layers by extracting high-level discriminative information from the features. The expression for using a higher-order classifier in the shallow stage is as follows:

[0050]

[0051] Among them, logits i HP represents the output of the classifier in the classification branch of the i-th stage. i Let S represent the higher-order classifier in the classification branch of the i-th stage, where i = 1, 2, 3, ..., S.

[0052] For deeper stages, the classifier expression is as follows:

[0053]

[0054] Among them, logits i LP represents the output of the classifier in the classification branch of the i-th stage. i Let represent the linear classifier in the classification branch of the i-th stage. Similar to the use of higher-order classifiers of different dimensions for different depths in shallow layers, deeper layers have strong high-level discriminative capabilities. Using a linear classifier can effectively train the stages. If a higher-order classifier is used again, it will not only increase the number of parameters, but also risk overfitting.

[0055] S3: In each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss at each stage.

[0056] Considering that samples exit based on confidence levels during inference, a learnable confidence factor is added to enhance the classifier's confidence in the classification results, especially for shallow classifiers that are not inherently suitable for classification. This makes the final classification prediction result more prominent. The confidence factor is related to the output logits. i Multiply them, and the predicted classification probabilities obtained after multiplication are:

[0057]

[0058] Where, β i Let be the confidence factor for stage i. This represents the predicted classification probability in the i-th stage. The loss is obtained by calculating the cross-entropy with the label Y corresponding to the input image. l i This represents the loss in stage i.

[0059] S4: In each classification branch, the loss from the previous stage is multiplied by the loss of the current stage as a dynamic adjustment parameter to obtain the dynamically adjusted loss for the current stage.

[0060] Because this invention increases the loss weight of the shallow layers in the later stages of training, when the shallow layers learn discriminative ability, the features input to the deeper layers will inevitably possess more discriminative information that the deeper layers do not need. Therefore, to reduce the influence of the shallow layers on the deeper layers, a dynamically adjusted parameter is set to control the dynamic update magnitude of the deeper layers. When the shallow layers provide high-level discriminative features suitable for classification, the control parameter helps reduce the update of features in the deeper layers. Conversely, if the shallow layers provide low-level representational features unsuitable for classification, the control parameter relaxes the restrictions on feature updates in the deeper layers. Thus, the loss of the shallow layers can be used as a parameter to control the final loss of the deeper layers. When the shallow layer loss is relatively large, the shallow layers input more representational features to the deeper layers, allowing for a larger update magnitude in the deeper layers. When the shallow layer loss is relatively small, the shallow layers input more discriminative features to the deeper layers, requiring a smaller update magnitude in the deeper layers. The final dynamically adjusted loss is expressed as follows:

[0061]

[0062] Among them, l i Let l represent the loss in stage i. i-1 This represents the loss in the (i-1)th stage. Let represent the loss after dynamic adjustment in stage i. σ represents the sigmoid activation function, which maps the loss of the previous layer to the range of 0 to 1. Specifically, for the same batch of sample images, when the loss of a sample in the same shallow layer is larger than that of other samples, it can be considered that the sample has more low-level representational information in the shallow layer, and the mapped value is relatively larger than that of other samples, meaning the influence of the shallow layer on the deep layer is weakened; when the loss of a sample in the same shallow layer is smaller than that of other samples, it can be considered that the sample has more high-level discriminative information in the shallow layer, and the mapped value is relatively smaller than that of other samples, meaning the influence of the shallow layer on the deep layer is enhanced.

[0063] S5: Sum the weighted losses after dynamic adjustment of all stages to obtain the final total loss, and use this total loss to train the inference-based, efficient dynamic optimization early termination model.

[0064] The final total loss is expressed as follows:

[0065]

[0066] in, This represents the total loss. α i This represents the dynamic loss weight for stage i. Different loss weight allocation strategies are used for shallow and deep layers at different training stages. Traditional weight allocation strategies generally fix the loss weights for each stage, and the weights for shallow layers are often smaller than those for deep layers. This often makes it difficult to achieve the learning of discriminative abilities in shallow layers, or to maintain the stability of deep layers while shallow layers are learning. To solve this problem, in the early stages of training, shallow layers should focus on learning low-level representational abilities, while deep layers should prioritize learning high-level discriminative abilities. Once sufficient discriminative abilities have been learned in deep layers, the goal is to gradually transfer these abilities to shallow layers as much as possible. Therefore, in the early stages of training, the dynamic loss weights for shallow layers are smaller than those for deep layers; in the later stages of training, the dynamic loss weights for shallow layers are larger than those for deep layers, so that the discriminative abilities of shallow layers are learned only after the discriminative abilities of deep layers have been fully learned.

[0067] S6: Employs a pre-trained, reasoning-based, efficient, dynamically optimized early termination model to perform reasoning classification on the input images. It determines at which stage an image should terminate based on the difficulty of its classification, avoiding all images going through the complete model architecture, thus achieving sample-level inference efficiency.

[0068] Based on the above principles, this invention also proposes a reasoning-based, dynamically optimized early termination system, which mainly includes:

[0069] The input module is used to input images into the established model;

[0070] A construction module is used to build an efficient dynamic optimization early termination model based on inference. The model adopts an early termination network and consists of S stages, where the output of the previous stage serves as the input of the next stage. Each stage's classification branch is equipped with a classifier, and each stage's classification branch inserts a lightweight side branch module and performs residual connections. The output of each stage serves as the input of the corresponding side branch module in its classification branch. The output of each stage and the output of its corresponding side branch module are residually connected to obtain classification features, which serve as the input of the classifier in the corresponding classification branch.

[0071] The training module is used to train the established inference-based efficient dynamic optimization early termination model. During training, in each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss of each stage. In each classification branch, the loss of the previous stage is used as a dynamic adjustment parameter and multiplied with the loss of the current stage to obtain the dynamically adjusted loss of the current stage. The weighted sum of the dynamically adjusted losses of all stages is used to obtain the final total loss, which is used to train the inference-based efficient dynamic optimization early termination model.

[0072] The prediction module is used to perform inference classification on the input image using a trained, inference-based, efficient, dynamically optimized early termination model.

[0073] Based on the above principles, this invention also proposes an electronic device, including a memory, a processor, and a computer program stored in the memory and executable on the processor. When the processor executes the computer program, it implements the dynamic optimization method of the reasoning-based efficient dynamic optimization early termination model described above.

[0074] Based on the above principles, this invention also proposes a computer-readable storage medium storing a computer program thereon. When the computer program is executed by a processor, it implements the above-mentioned dynamic optimization method for the reasoning-based efficient dynamic optimization early termination model.

[0075] Example

[0076] In this embodiment, the invention is evaluated using dataset image classification (VTAB-1K, CIFAR-100, CUB-200-2011, NABirds, Oxford Flowers, Stanford Cars, and Stanford Dogs) and few-shot learning (Food-101, Stanford Cars, Oxford Flower, FGVCAircraft, and OxfordPets).

[0077] The backbone network is ViT-B / 16, using LoRA as the fine-tuning module. The model network is divided into four stages (S=4), each with three ViT network blocks and one classifier. The AdamW optimization algorithm and cosine annealing training strategy are employed. The lightweight side-branch modules are consistent with the fine-tuning modules used in the network, also employing LoRA modules. Considering the potential of higher-order classifiers to improve network performance using shallow network architectures, higher-order classifiers are only used in the first two stages, employing the Moment Probing (MP) method. Furthermore, considering that different stages in the shallow layer also have relative depth, and that the discriminative power of stages increases with depth, shallower stages use higher-dimensional higher-order classifiers with stronger discriminative information extraction capabilities, while deeper stages, which inherently possess good high-level discriminative power, use lower-dimensional higher-order classifiers.

[0078] At the start of training, the dynamic loss weights for the four phases were 0.01, 0.01, 1.0, and 2.0, respectively.

[0079] At the end of training, the dynamic loss weights for the four stages are 1.5, 1.0, 0.1, and 0.1, respectively, and each stage's dynamic loss weight is a linear transformation. The confidence factors for all four stages are initialized to 1.

[0080] All programs are implemented in PyTorch and run on eight RTX 3090 GPUs.

[0081] Although the functions and working processes of the present invention have been described above in conjunction with the accompanying drawings, the present invention is not limited to the specific functions and working processes described above. The specific embodiments described above are merely illustrative and not restrictive. Those skilled in the art can make many other forms under the guidance of the present invention without departing from the spirit and scope of the claims, and all of these are within the protection scope of the present invention.

Claims

1. A dynamic optimization method for an efficient dynamic optimization model of early termination based on reasoning, characterized in that, The inference-based, efficient, dynamically optimized early-retreat model employs an early-retreat network consisting of S stages. The output of the previous stage serves as the input to the next stage. Each stage's classification branch includes a classifier. The key feature is that each stage's classification branch incorporates a lightweight side-branch module with residual connections. The output of each stage serves as the input to the corresponding side-branch module within its classification branch. The output of each stage and the output of its corresponding side-branch module are residually connected to obtain classification features, which then serve as the input to the classifier in the corresponding classification branch. The dynamic optimization process specifically includes the following steps: S1: The input image is processed sequentially through each stage of the reasoning-based efficient dynamic optimization early termination model, and the output features of each stage are input into its corresponding classification branch and the next stage. S2: In each classification branch, the output features of each stage are processed by the corresponding side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier. S3: In each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss at each stage; S4: In each classification branch, the loss from the previous stage is multiplied by the loss in the current stage as a dynamic adjustment parameter to obtain the dynamically adjusted loss for the current stage. S5: Sum the weighted losses after all stages of dynamic adjustment to obtain the final total loss, and use this total loss to train the inference-based, efficient dynamic optimization early termination model; The total loss is obtained according to the following formula: , in, Indicates the total loss; This represents the dynamic loss weight in the i-th stage. In the early stage of training, the dynamic loss weight of the shallow layer is smaller than that of the deep layer. In the later stage of training, the dynamic loss weight of the shallow layer is larger than that of the deep layer. This represents the loss after dynamic adjustment in stage i; S6: Use a trained, reasoning-based, efficient, dynamically optimized early termination model to perform reasoning classification on the input image.

2. The dynamic optimization method for the reasoning-efficient dynamic optimization early termination model according to claim 1, characterized in that, The dynamically adjusted loss described in step S4 is calculated using the following formula: , in, This represents the loss in stage i. This represents the loss after dynamic adjustment in stage i. This represents the sigmoid activation function.

3. The dynamic optimization method for the reasoning-efficient dynamic optimization early termination model according to claim 1, characterized in that, The backbone network of each stage is a ViT network, and the fine-tuning modules used are either LoRA modules or Adapter modules.

4. The dynamic optimization method for the reasoning-based efficient dynamic optimization early termination model according to claim 1, characterized in that, Shallow classifiers use higher-order classifiers, while deep classifiers use linear classifiers.

5. The dynamic optimization method for the reasoning-efficient dynamic optimization early termination model according to claim 1, characterized in that, Each of the side branch modules adopts a LoRA module or an Adapter module; in each classification branch, the output features of the corresponding stage are processed by the side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier.

6. A reasoning-based, efficient, dynamically optimized early termination system, characterized in that, include: A construction module is used to build an efficient dynamic optimization early termination model based on inference. The model adopts an early termination network and consists of S stages, where the output of the previous stage is used as the input of the next stage. Each stage's classification branch is equipped with a classifier, and each stage's classification branch inserts a lightweight side branch module and performs residual connections. The output of each stage is used as the input of the corresponding side branch module in its classification branch. The output of each stage and the output of its corresponding side branch module are residually connected to obtain the classification features, which are used as the input of the classifier in the corresponding classification branch. The input module is used to input images into the established inference-based efficient dynamic optimization early termination model. The input images are processed sequentially through each stage of the inference-based efficient dynamic optimization early termination model. The output features of each stage are input into its corresponding classification branch and the next stage. In each classification branch, the output features of each stage are processed by the corresponding side branch module and then residually connected with the output features of the corresponding stage to obtain new classification features for each stage, which are then input into the corresponding classifier. The training module is used to train the established reasoning-based, efficient, dynamically optimized early termination model. During training, in each classification branch, the output of each classifier is multiplied by the confidence factor, then passed through the softmax function to obtain the predicted classification probability value, and then the cross-entropy is calculated with the label corresponding to the input image to obtain the loss of each stage; in each classification branch, the loss of the previous stage is used as a dynamic adjustment parameter and multiplied with the loss of the current stage to obtain the dynamically adjusted loss of the current stage. The weighted sum of the losses after dynamic adjustment in all stages is used to obtain the final total loss. This total loss is then used to train the inference-based, dynamic optimization early termination model. The prediction module is used to perform inference classification on the input image using a trained, inference-based, efficient, dynamically optimized early termination model.

7. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, When the processor executes the computer program, it implements the dynamic optimization method for the reasoning-efficient dynamic optimization early termination model as described in any one of claims 1 to 5.

8. A computer-readable storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements the dynamic optimization method for the reasoning-efficient dynamic optimization early termination model as described in any one of claims 1 to 5.

Citation Information

Patent Citations

  • Neural network reasoning optimization method, device and equipment and readable storage medium

    CN115841590A

  • Inference acceleration method and device based on collaborative meta-learning

    CN116484839A