An embedded online compression method for multimodal networks

By using model weight slicing and dynamic reasoning technology on embedded devices, the structure of the deep multi-modal model is dynamically adjusted, solving the problem of multi-modal network compression on resource-constrained devices, achieving efficient calculation and accuracy improvement, and is suitable for in multi-modal dynamic reasoning scenarios.

CN118194934BActive Publication Date: 2024-09-27TIANJIN UNIV +1
View PDF 4 Cites 0 Cited by

Patent Information

Application Number
CN202410291170.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-03-14
Publication Date
2024-09-27
Estimated Expiration
2044-03-14

AI Technical Summary

Technical Problem

Existing technologies are difficult to effectively compress deep multi-modal fusion networks (DMFN) online on resource-constrained embedded devices, and existing methods cannot automatically adjust the model structure to adapt to the complexity of multi-modal inputs and differences in modal contributions. This results in a waste of computing resources and loss of accuracy.

Method used

Using model weight slicing technology, multi-modal model dynamic reasoning technology and neural network calculation graph upgrade technology, dynamic component construction, model calculation graph upgrade, dynamic multi-modal model generation and model joint training are used to realize the embedding of deep multi-modal models. Deploy and compress online, adjust the model structure based on input and generate policy networks to optimize computational efficiency.

Benefits of technology

It realizes multi-modal online compression on embedded devices without manual modification of the model calculation graph, automatically adjusts the model structure to adapt to different inputs, improves calculation efficiency and accuracy, reduces calculation delay and energy consumption, and is suitable for multi-modal dynamics. reasoning scenario.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118194934B
    Figure CN118194934B
Patent Text Reader

Abstract

The present invention discloses an embedded online compression method for multimodal networks, belonging to the technical field of inference optimization when neural networks are deployed in embedded devices; the present invention introduces lightweight dynamic components to enable the model to dynamically change its structure during inference; then, a model analyzer and a conversion module are designed, and these dynamic components are used to upgrade the original static model to obtain a dynamic backbone model, which can generate multiple sub-models to handle different computing requirements of multimodal inputs; then, according to the shape of the multimodal input and the preset generation strategy network, an end-to-end compression strategy is generated for each component and module, and the model structure is adjusted; finally, the strategy model and the backbone model are combined to obtain a dynamic DMFN. For each sample, the upgraded DMFN can complete inference on the device according to the compression strategy without retraining, has better inference performance, and reduces average runtime delay and energy consumption.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to inference optimization when an embedded device deploys a neural network, and in particular to an embedded online compression method for a multimodal network. Background Art

[0002] In recent years, the field of Internet of Things has developed rapidly, and the scale of deployment and number of connections of IoT devices have also exploded year by year. Universal IoT devices, such as sensors, cameras, microphones, etc., can obtain a variety of perception data from the environment from different angles and provide multimodal information to perceive complex environments. These multimodal data have a wide range of applications in IoT applications and can be used in environmental monitoring, smart homes, smart transportation and other fields. According to a report, by 2025, IoT devices will generate more than 79ZB of massive data. Such a huge amount of data will bring major challenges to data transmission and privacy protection.

[0003] In order to meet these challenges, the trend in recent years has been to transfer data processing from large-scale cloud data centers to local devices, and to delegate computing tasks from the cloud to edge devices and terminal devices that are closer to the data source for processing, which can reduce data transmission delays, reduce network load, and provide better privacy protection. Deep multimodal machine learning plays a key role in processing multimodal data generated by ubiquitous IoT devices. It can fuse data from different modalities to improve the ability to understand and analyze the environment.

[0004] In this context, the Deep Multi-modal Fusion Network (DMFN) was proposed to process multimodal data. The Deep Multi-modal Fusion Network (DMFN) can input data of different modalities into the model, and by learning effective fusion strategies, it can fuse and extract multimodal information to obtain more expressive feature representations. However, due to the complexity and large number of parameters of the Deep Multi-modal Fusion Network (DMFN), it has a high demand for computing resources, which conflicts with the limited local resources of embedded devices.

[0005] To this end, model compression schemes can be used to reduce computational costs and balance accuracy and efficiency. However, most existing works are based on single-modal neural network designs. The limitation of existing methods is that they need to manually modify the computational graph to improve a specific model structure, which is costly when applied to deep multimodal fusion networks (DMFNs) of different structures. In addition, when changing the compression strategy or applying different model components, it is necessary to rely on expert experience to adjust the model structure, which cannot handle the complexity differences and contribution differences of multimodal samples. Offline compression methods such as parameter pruning, weight quantization, and knowledge distillation require manual design to reduce model complexity. These methods have a fixed compression ratio for different inputs, ignoring the complexity of multimodal inputs, resulting in wasted computational resources on simple samples. In addition, in order to avoid severe loss of accuracy when changing the compression ratio, these methods require offline retraining. In contrast, online compression techniques can allocate the necessary computational amount by adjusting the model structure for inputs of different complexities. However, these methods ignore the differences in modal contributions between samples, resulting in a waste of computational costs in deep multimodal fusion networks (DMFNs) when processing redundant or unimportant modalities. The 2023 work DynMM realizes dynamic multimodal fusion by reconstructing a series of expert networks, but it still requires manual selection of expert networks and cannot automatically modify the computational graph.

[0006] In order to solve the above problems, the present invention proposes an embedded online compression method for multimodal networks. Summary of the invention

[0007] 1. Technical Problems to be Solved by the Present Invention

[0008] The purpose of the present invention is to propose an embedded online compression method for multimodal networks to achieve timely online compression of different deep multimodal fusion networks (DMFNs) on resource-constrained devices.

[0009] 2. Technical solution

[0010] To achieve the above object, the present invention provides the following technical solutions:

[0011] An embedded online compression method for multimodal networks is proposed. The method is based on model weight slicing technology, multimodal model dynamic reasoning technology and neural network calculation graph upgrade technology to achieve embedded deployment of deep multimodal models. The specific implementation method is as follows:

[0012] S1. Dynamic component construction: Reconstruct the component, add a control parameter to the component, slice the component weight during calculation, change the number of neurons actually involved in the calculation, so as to realize the dynamic calculation and results at the component granularity; design dimension-related jump connections to realize structural variability at the layer granularity;

[0013] S2. Model calculation graph upgrade: Design a model calculation graph upgrade module, iteratively read the configuration of each part of the model according to the tree structure, schedule the corresponding dynamic components to re-assign values, and add jump connections to the feature extraction modules in the model according to the preset settings to reduce the calculation of unimportant modes;

[0014] S3, dynamic multimodal model generation: first, the dynamic backbone is obtained by upgrading the original static model to provide the basis for reasoning; then, according to the defined number of compression strategies and the input settings of the multimodal model, the strategy network model is generated in combination with the set strategy network structure; finally, the strategy network and the dynamic backbone are spliced ​​to form a dynamic deep multimodal fusion network (DMFN); the dynamic deep multimodal fusion network (DMFN) is divided into two steps during calculation: the strategy model accepts input to generate a structure adjustment strategy, and the dynamic backbone changes the structure according to the strategy and completes the reasoning;

[0015] S4. Joint model training: Design a greedy strategy loss to guide strategy generation based on the change in prediction loss before and after the model structure changes; use knowledge distillation and joint training to improve the accuracy of the model, and rely on calculating penalty loss to improve the computational efficiency of the model.

[0016] Preferably, the S1 specifically includes the following contents:

[0017] S1.1. Partially inactivate a dimension of the weight within a layer through weight slicing technology to reduce the amount of calculation and change the feature dimension; the slicing operation acts on both the input and output dimensions;

[0018] S1.2, increase the operation route in the model to change the depth, introduce skip connections, and replace the original module for calculation when performing skip layer operations;

[0019] The jump connection described in S1.3 and S1.2 is related to the input and output configuration of the module. Based on the idea of ​​depthwise separable convolution, the features are compressed and aligned from different dimensions, and the input and output tensors of the module are classified into three categories according to the dimensions: one-dimensional data, two-dimensional data, and three-dimensional data.

[0020] S1.4. For 2D and 3D data, downsample the data through a pooling layer, and then use a convolutional layer with a kernel size of 1 to compress the information along the channel dimension. After reshaping the features, use two fully connected layers for feature fusion and dimension adjustment, and then reshape the intermediate features to align with the other dimensions of the module output besides the channel. Finally, use another convolutional layer with a kernel size of 1 to align their channel dimensions.

[0021] S1.5. For one-dimensional data, two fully connected layers are used to align their features. When the channel dimension of other dimensional data is 1, the input is directly flattened and treated as one-dimensional data.

[0022] Preferably, S2 specifically includes the following contents:

[0023] S2.1. The deep multimodal fusion network (DMFN) is considered as a tree structure, where the model index is the root index, the module is the child node, and the layer is the leaf node;

[0024] S2.2, for each module in the deep multimodal fusion network (DMFN), first read the configuration of each base layer in the module, and replace the corresponding dynamic components according to the configuration definition; before replacement, the user selectively retains part of the static base layer;

[0025] S2.3. Perform different processing on the base layers at different locations to ensure that the reasoning function remains unchanged. Specifically:

[0026] For the input layer of the module, the dynamic component used for replacement first reads the input channel dimension of the data, calculates the corresponding slice ratio with the component weight input dimension size, and completes the slicing along the input dimension; then, according to the proportional coefficient passed into the module, completes the slicing along the output dimension; for the static component that remains unchanged, the weight of the previous layer is only sliced ​​along the input dimension, and the weight of the next layer is only sliced ​​along the output dimension;

[0027] For the output layer of the module, only slice along the input dimension;

[0028] For other layers, their weights are sliced ​​in equal proportions in both dimensions according to the coefficients passed in by the module;

[0029] S2.4. Define jump connections with the same input and output configuration for corresponding modules, then regard the modules that have completed dynamic component replacement as a whole, form a dual-channel module side by side with the jump connection, and add the same gating design before and after the new module; when the proportional coefficient r introduced into the module is 0, that is, in the case of full slicing, the present invention activates the jump connection and deactivates the original module, and uses the jump connection to complete the reasoning; when the proportional coefficient r≠0, the original module is weight-sliced ​​to complete the reasoning.

[0030] Preferably, S3 specifically includes the following contents:

[0031] S3.1. Take multimodal samples as the input of the policy network, compress and extract the features of different modal parts respectively, and then modify the backbone network structure according to the spliced ​​feature generation structure adjustment strategy to achieve dynamic reasoning;

[0032] S3.2. Divide the data compression layer of the strategy network based on different modal tensor data, specifically: one-dimensional data Two-dimensional data and 3D data For one-dimensional data, the data compression layer is a fully connected layer with input dimension a and output dimension a / / p, where / / represents integer division; for two-dimensional and three-dimensional data, the data compression layer is a convolutional layer with input channel dimension a, output channel dimension 1, and kernel size and stride both set to p;

[0033] S3.3, flatten the acquired features, use the independent fully connected layer with output dimension h1 of each branch to further extract features, and then concatenate them to get where h 2 Indicates the number of branches;

[0034] S3.4, use two fully connected layers as the decision part of the policy network and obtain Among them, N M represents the number of modules, and K represents the number of strategy types;

[0035] S3.5. Use one-hot encoding to represent different compression strategies, and use the Argmax function to obtain the final strategy gout; the strategy network is jointly trained with the backbone network to learn how to make decisions automatically.

[0036] Preferably, the S4 specifically includes the following contents:

[0037] S4.1. After generating the dynamic deep multimodal fusion network (DMFN), by setting different structural adjustment strategies, running different subnetworks in the dynamic deep multimodal fusion network (DMFN) to obtain multiple outputs, so as to better train the various parts of the dynamic deep multimodal fusion network (DMFN);

[0038] Taking a dual-modal deep multimodal fusion network (DMFN) as an example, the model is based on X 0 and X 1 As input, B si , B di and B li They represent the output of the i-th module using skip connections, the output of the application generation strategy, and the output of the original module respectively; the output of running the multi-subnetwork is as follows:

[0039] S4.1.1. Run the original deep multimodal fusion network (DMFN) to get the output:

[0040] Y l =B l2 (B l0 (X 0 ),B l1 (X 1 ))

[0041] S4.1.2. Activate all skip connections and run the smallest subnetwork to get the output:

[0042] Y s =B s2 (B s0 (X 0 ),B s1 (X 1 ))

[0043] S4.1.3. Run the dynamic subnetwork of the application strategy network to generate the strategy and obtain the outputs respectively:

[0044] Y d =B d2 (B d0 (X 0 ),B d1 (X 1 ))

[0045] S4.1.4. Activate the skip connections of each module independently and run the sub-network to obtain the following output:

[0046] Y 0 =B l2 (B s0 (X 0 ),B l1 (X 1 ))

[0047] Y 1 =B l2 (B l0 (X 0 ),B s1 (X 1 ))

[0048] Y 2 =B s2 (B l0 (X 0 ),B l1 (X 1 ))

[0049] S4.1.5. Calculate the prediction loss based on the multiple outputs obtained:

[0050] L lce =CELoss(Y l ,Label)

[0051] L dce =CELoss(Y d ,Label)

[0052] L sce =CELoss(Y s ,Label)

[0053] Among them, CELoss(·) represents the cross entropy loss;

[0054] S4.2. Use knowledge distillation technology to transfer knowledge from the original model to improve the overall performance of the model. The specific function is expressed as:

[0055] L lts =MSELoss(Y s2 ,Y l2 )

[0056] Among them, MSELoss(·) represents the mean square error loss, Y s2 and Y l2 They represent the output features of the penultimate layer of the Deep Multimodal Fusion Network (DMFN);

[0057] S4.3. Design a greedy random loss to guide the policy network to generate a more favorable strategy: When the model contains N compressible modules and K types of compression strategies, by setting the compression strategy of one module to 0 and not compressing other modules, ACF generates a set of loss sequences L d =(d 0 ,d 1 ,…,d N-1 ); Run the model N times and get the label Y g =(g 0 ,g 1 ,…,g N-1 ) for policy network training:

[0058]

[0059] That is, when the module is compressed, if the loss decreases, it is regarded as a positive benefit, encouraging this compression strategy and generating a larger compression coefficient; otherwise, it is regarded as a negative benefit, suppressing this compression strategy and generating a smaller compression coefficient, thereby avoiding excessive information loss;

[0060] S4.4. Calculate the greedy random loss as follows:

[0061] L dce =CELoss(Y d ,Label)

[0062] The introduction of computational penalty loss enables the policy network to generate a lighter policy. The specific function is expressed as follows:

[0063]

[0064] Among them, SMACs(·) represents the computational amount of the dynamic deep multimodal fusion network (DMFN) after applying the generation strategy, K represents the computational amount of the original model, X represents the input, θ dynamic Indicates the weight involved in the calculation;

[0065] S4.5. Combining the contents of S4.1-S4.4, the total loss function applied in the training phase is expressed as follows:

[0066] L total =L sce +L dce +L lce +L lts +L g +λ·L MAC

[0067] Among them, λ represents a number between 0 and 1, which is used to adjust the impact of the penalty for computational loss;

[0068] S4.6. After training, the dynamic deep multimodal fusion network (DMFN) replaces the original model and is deployed locally on the device to participate in the reasoning task. In the reasoning stage, the dynamic deep multimodal fusion network (DMFN) first executes the policy network to generate the structural adjustment strategy for all modules in the deep multimodal fusion network (DMFN), and distributes it to the corresponding modules. Each module shares the same structural adjustment strategy, and different modules can use different adjustment strategies. Finally, the model completes the reasoning task of the input sample with a lightweight structure adjusted in real time.

[0069] 3. Beneficial effects

[0070] (1) The present invention implements a general multimodal online compression framework that is independent of the specific model structure. By applying this framework, the width and depth of the DMFN can be adjusted in real time according to the complexity of the sample during local reasoning on the embedded device. Compared with previous model compression work, the present invention does not require manual modification of the model calculation graph, and for the first time simultaneously considers the contribution differences between multiple modalities and the quality differences of samples within the modality. It is more versatile and more in line with the application requirements of multimodal dynamic reasoning scenarios.

[0071] (2) We design a computationally lightweight policy network that is automatically generated based on the original input and the number of optional policies, decoupled from the backbone network, and runs at a very low cost on a local embedded device to generate sample-level policies for different modules of the DMFN.

[0072] (3) The present invention designs a greedy random loss function and a mask filling module to ensure that the upgraded DMFN has dynamic diversity and prevents it from overfitting, thereby improving the performance of DMFN training.

[0073] (4) The present invention experimentally verifies multiple DMFN application scenarios on different embedded platforms, including emotion recognition, action recognition, and handwritten digit recognition. Without relying on hardware acceleration and retraining, the present invention outperforms all benchmark methods in terms of computational complexity, accuracy, latency, and energy consumption. BRIEF DESCRIPTION OF THE DRAWINGS

[0074] Figure 1 This is a schematic diagram of weight slicing along the output dimension mentioned in Embodiment 1 of the present invention;

[0075] Figure 2 This is a schematic diagram of dimension-related jump connections mentioned in Embodiment 1 of the present invention;

[0076] Figure 3 This is a schematic diagram of the DMFN tree structure index mentioned in Example 1 of the present invention;

[0077] Figure 4 This is a schematic diagram of updating the model calculation graph mentioned in Example 1 of the present invention;

[0078] Figure 5 This is a schematic diagram of a lightweight policy network mentioned in Example 1 of the present invention;

[0079] Figure 6 This is the training data flow diagram mentioned in Example 1 of the present invention. DETAILED DESCRIPTION

[0080] In order to make the above-mentioned objects, features and advantages of the present invention more obvious and easy to understand, the specific implementation methods of the present invention are described in detail below in conjunction with the accompanying drawings.

[0081] In the following description, many specific details are set forth to facilitate a full understanding of the present invention, but the present invention may also be implemented in other ways different from those described herein, and those skilled in the art may make similar generalizations without violating the connotation of the present invention. Therefore, the present invention is not limited to the specific embodiments disclosed below.

[0082] Secondly, the term "one embodiment" or "embodiment" as used herein refers to a specific feature, structure, or characteristic that may be included in at least one implementation of the present invention. The term "in one embodiment" that appears in different places in this specification does not necessarily refer to the same embodiment, nor does it refer to a separate or selective embodiment that is mutually exclusive with other embodiments.

[0083] The present invention aims to propose an embedded online compression method for multimodal networks. The basic principle is to construct dynamic components and model calculation graph upgrade modules, automatically modify the multimodal network so that it can change the model structure in real time during reasoning, and automatically generate the corresponding strategy model according to the multimodal input shape and preset configuration, and generate structural adjustment strategies for each part of the model for each reasoning, thereby realizing the adaptive structural adjustment of the multimodal network to the input samples, achieving better reasoning performance, and reducing average runtime latency and energy consumption.

[0084] Terminology explanation:

[0085] Inference optimization is a technology that aims at limited resources of embedded devices, improves the operating efficiency of deep neural networks, and reduces indicators such as model latency, energy consumption and memory. It is one of the necessary links in the deployment of neural networks. Existing technologies mainly optimize inference from three perspectives: optimizing the model operation process, reducing the model calculation amount and improving the utilization of hardware resources.

[0086] The multimodal fusion network is a deep learning model designed for multimodal data. It aims to process and fuse data from multiple different data sources. The model usually includes feature extraction module, fusion module and decision module. Common modalities include images, text, speech, video, etc.

[0087] Model pruning refers to reducing the number of model parameters and the number of neuron connections within the model through some heuristic rules, thereby reducing the model calculation cost while maintaining the model performance. Model pruning can be divided into structured pruning and unstructured pruning, among which structured pruning can achieve real acceleration without special hardware support.

[0088] Dynamic reasoning means that when applying a deep learning model, the model can dynamically select different calculation paths and operations within the model for reasoning and prediction based on the characteristics of the input data and contextual information. The dynamic reasoning model corresponds to the traditional static model, which defines a certain calculation path and operation order during model training.

[0089] A model computation graph is a graph structure used to describe the computational flow and operational dependencies in a deep learning model. The computation graph represents the connections and flows between the various layers, computational nodes, and computational operations in the model.

[0090] The policy model refers to an additional neural network model that guides the model to modify the computational graph during dynamic reasoning. The policy model takes the original input or intermediate features of the model as input, and outputs the strategy for adjusting the structure of each part of the reasoning model, thereby guiding the model to call model pruning operations, selectively execute various layers of the model, change the way computing nodes are connected, etc.

[0091] Based on the above content, a human-computer interaction control method based on an acoustic wearable device proposed in the present invention is described below in combination with a specific example, and the specific content is as follows.

[0092] Embodiment 1:

[0093] The present invention is based on the widely used deep learning framework Pytorch, builds the software prototype of the present invention, and applies it to different DMFNs, and deploys it on various embedded devices such as Raspberry Pi 3B and Raspberry Pi 4B. The present invention provides three input interfaces, which correspond to the input tensor configuration of DMFN, the structure adjustment policy setting given by the user, and the DMFN index, and then automatically generates a lightweight policy network according to the policy setting and the input tensor configuration, and indexes the input DMFN at the same time. The framework automatically analyzes the calculation graph of DMFN and calls the corresponding dynamic component to upgrade DMFN to obtain a dynamic trunk, and splices the dynamic trunk and the policy network to output a dynamic DMFN. The dynamic DMFN output by the present invention does not change the original input and output settings. For this reason, after generating the dynamic DMFN, it replaces the original static DMFN with it, and calls the training function in the software to complete the model training. After the model is trained, the present invention uses a variety of embedded devices and desktop computers to execute the code written in Python to complete the deployment test.

[0094] Dynamic component construction part:

[0095] When upgrading DMFN, the present invention needs to replace the original components with dynamic components to transform DMFN from a fixed structure model to a multi-capacity model that can derive multiple sub-models, and can be adjusted in width and depth.

[0096] In order to realize the real-time variable width of DMFN, that is, the number of neurons in the layer can be changed, such as Figure 1 As shown in the figure, the present invention uses weight slicing technology to inactivate a certain dimension of the weight in the layer to reduce the amount of calculation and change the feature dimension. Taking the fully connected layer as an example, assuming that the parameter matrix of the original component is where c o and c i Represent the output dimension and input dimension of the component respectively. In order to omit the parameter importance sorting and indexing time, the present invention slices a continuous address space from the beginning of the matrix index to store the parameters for calculation. When the compression ratio of the component is 1-r, the weights after slicing the output and input dimensions can be expressed as and Used to change the shape of intermediate features and ensure correct reasoning. Slicing operations can also act on both input and output dimensions.

[0097] In order to achieve real-time variable depth of DMFN, that is, to change the number of layers involved in the calculation in the module of the model, the present invention achieves the purpose of changing the depth by increasing the calculation route in the model. This method is similar to the residual connection in the residual network, except that the jump connection introduced in the present invention is only used to replace the original module for calculation when performing the jump layer operation. Figure 2 As shown, the lightweight jump connection proposed in the present invention is related to the input and output configuration of the module. Specifically, due to the heterogeneity of multimodal inputs and the differences between different DMFNs, the input and output of the module are significantly different. Inspired by the idea of ​​deep separable convolution, the present invention compresses and aligns features from different dimensions respectively, and classifies the input and output tensors of the module into three categories according to the dimensions. For two-dimensional and three-dimensional data, the present invention downsamples the data through a pooling layer, and then uses a convolutional layer with a kernel size of 1 to compress the information along the channel dimension. After reshaping the feature shape, two fully connected layers are used for feature fusion and dimensionality adjustment, and then the intermediate features are reshaped to align with other dimensions of the module output outside the channel. Finally, the present invention uses another convolutional layer with a kernel size of 1 to align their channel dimensions. For one-dimensional data, only two fully connected layers are used to align their features. In addition, when the channel dimension of other dimensional data is 1, the present invention directly flattens the input and treats it as one-dimensional data for processing.

[0098] Model calculation graph upgrade part:

[0099] Specifically, the present invention regards DMFN as a tree structure, such as Figure 3 As shown in , the model index is the root index, the module is the child node, and the layer is the leaf node. Hierarchical Upgrading DMFN, during dynamic reasoning, the structure of the jump connection embedded in the dynamic DMFN is fixed. Therefore, Figure 4 As shown, for each module in DMFN, the present invention first reads the configuration of each base layer in the module, and replaces the corresponding dynamic components according to the configuration definition. Before replacement, the user can set the static part, that is, selectively retain part of the static base layer. In the process of replacing components, weight slicing will change the intermediate features of the module, thereby affecting the normal progress of the reasoning process.

[0100] In this regard, the present invention has different processing for the base layers at different positions to ensure that the reasoning function remains unchanged. Specifically, for the input layer (first layer) of the module, the dynamic component used for replacement first reads the input channel dimension of the data, calculates the corresponding slicing ratio with the component weight input dimension size, completes the slicing along the input dimension, and then completes the slicing along the output dimension according to the proportional coefficient passed into the module. For the static components that remain unchanged, the weights of the previous layer are only sliced ​​along the input dimension, and the weights of the next layer are only sliced ​​along the output dimension. For the output layer of the module, it is also sliced ​​only along the input dimension. For other layers, the weights are sliced ​​in equal proportions on the two dimensions according to the coefficients passed in by the module.

[0101] Secondly, according to the preset jump structure and the input and output configuration of the module, the present invention defines jump connections with the same input and output configuration for the corresponding modules. Figure 4 , the present invention regards the module that has completed dynamic component replacement as a whole, forms a dual-channel module side by side with the jump connection, and adds the same gating design before and after the new module. Only when the proportional coefficient r=0 passed into the module, that is, in the case of full slicing, the present invention activates the jump connection and deactivates the original module, and uses the jump connection to complete the reasoning. When the proportional coefficient r≠0, the original module is weighted sliced ​​to complete the reasoning.

[0102] Dynamic multimodal model generation part:

[0103] Different DMFNs have different input settings, and multimodal inputs are highly complex and redundant, so it is difficult to manually design rules to generate corresponding compression strategies for each sample. To this end, the present invention designs an end-to-end lightweight strategy network, which is spliced ​​with the backbone network to form a dynamic multimodal model.

[0104] Specifically, the policy network takes the original multimodal samples as input, compresses and extracts the features of different modal parts respectively, and then modifies the backbone network structure according to the structure adjustment strategy generated by the spliced ​​features, thereby achieving dynamic reasoning. Figure 5 , the strategy network is mainly divided into three parts: data compression, feature extraction, fusion and output strategy. In the data compression layer, different modal tensor data are also divided by dimension: one-dimensional data Two-dimensional data and 3D data For one-dimensional data, the data compression layer is a fully connected layer with input dimension a and output dimension a / / p. / / represents integer division. For two-dimensional and three-dimensional data, the data compression layer is a convolutional layer with input channel dimension a, output channel dimension 1, and kernel size and stride both set to p. Then, the acquired features are flattened and the output dimension of each branch is h. 1The independent fully connected layer further extracts features and is concatenated to obtain where h 2 is the number of branches. Finally, two fully connected layers are used as the decision part of the policy network and after reshaping and segmentation, N M represents the number of modules, and K represents the number of strategy types. The present invention uses unique hot encoding to represent different compression strategies, and uses the Argmax function to obtain the final strategy gout. The strategy network is jointly trained with the backbone network to learn how to make decisions automatically.

[0105] Model joint training and testing part:

[0106] After generating the dynamic DMFN, the present invention sets different structural adjustment strategies to run different subnets in the dynamic DMFN to obtain multiple outputs, so as to better train the various parts of the dynamic DMFN. Figure 6 As shown, taking a bimodal DMFN as an example, the model is based on X 0 and X1 as input, with B si , B di and B li They represent the output of the i-th module using the output of the skip connection to apply the generation strategy, and the output of the original module. The output of running the multi-subnetwork is as follows:

[0107] First, run the original DMFN (largest subnetwork) to get the output:

[0108] Y l =B l2 (B l0 (X 0 ),B l1 (X 1 )).

[0109] Second, activate all skip connections and run the smallest subnetwork to get the output:

[0110] Y s =B s2 (B s0 (X 0 ),B s1 (X 1 )).

[0111] Third, run the dynamic subnetwork of the application policy network to generate the policy and get the output respectively:

[0112] Y d =B d2 (B d0 (X 0 ),B d1 (X 1 )).

[0113] Fourth, independently activate the skip connections of each module and run the sub-network to get the following output:

[0114] Y 0 =B l2 (B s0 (X 0 ),B l1 (X 1 )),

[0115] Y 1 =B l2 (B l0 (X 0 ),B s1 (X 1 )),

[0116] Y 2 =B s2 (B l0 (X 0 ),B l1 (X 1 )).

[0117] Based on the multiple outputs obtained, the prediction loss is first calculated:

[0118]

[0119]

[0120]

[0121] where CELoss(·) represents the cross entropy loss.

[0122] When training dynamic DMFN, the minimum subnetwork significantly reduces the amount of model computation, and it is difficult to guarantee the performance of skip connections by only guiding training with prediction loss.

[0123] To this end, the present invention uses knowledge distillation technology to transfer knowledge from the original model to improve the overall performance of the model:

[0124]

[0125] Where MSELoss(·) represents the mean square error loss, Y s2 and Y l2 They represent the output features of the penultimate layer of DMFN respectively.

[0126] In addition to effectively training the dynamic backbone, training the policy network determines the quality of the generated policy. This paper designs a greedy random loss to guide the policy network to generate a more favorable policy. In the case where the model contains N compressible modules and K types of compression strategies, by setting the compression strategy of one module to 0 and not compressing other modules, ACF generates a set of loss sequences L d =(d 0 ,d 1 ,…,d N-1 ). This method only requires running the model N times. Then we get the label Y g =(g 0 ,g 1 ,…,g N-1 ) for policy network training:

[0127]

[0128] That is, when the module is compressed, if the loss decreases, it is considered a positive gain, encouraging this compression strategy and generating a larger compression coefficient. Otherwise, it is considered a negative gain, suppressing this compression strategy and generating a smaller compression coefficient, thereby avoiding excessive information loss. After that, the greedy random loss is calculated as follows:

[0129]

[0130] In order to make the policy network generate a lighter policy, a computational penalty loss is introduced:

[0131]

[0132] where SMACs(·) represents the computational effort of the dynamic DMFN after applying the generation strategy, K represents the computational effort of the original model, X represents the input, and θ dynamic Represents the weight involved in the calculation.

[0133] In summary, the total loss applied in the training phase of the present invention is as follows:

[0134]

[0135] Where λ is a number between 0 and 1, which is used to adjust the impact of the computational loss penalty.

[0136] After training, the dynamic DMFN replaces the original model and is deployed locally on the device to participate in the reasoning task. In the reasoning stage, the dynamic DMFN first executes the policy network to generate the structural adjustment strategy for all modules in the DMFN and distributes it to the corresponding modules. Each module shares the same structural adjustment strategy, and different modules can use different adjustment strategies. Finally, the model completes the reasoning task of the input sample with a lightweight structure adjusted in real time.

[0137] The above description is only a preferred specific implementation manner of the present invention, but the protection scope of the present invention is not limited thereto. Any technician familiar with the technical field can make equivalent replacements or changes according to the technical scheme and improved concepts of the present invention within the technical scope disclosed by the present invention, and they should be covered by the protection scope of the present invention.

Claims

1. An embedded online compression method for multimodal networks, characterized in that: The method is based on model weight slicing technology, multimodal model dynamic reasoning technology and neural network calculation graph upgrade technology to achieve embedded deployment of deep multimodal models. The specific implementation method is as follows: S1. Dynamic component construction: Reconstruct the component, add a control parameter to the component, slice the component weight during calculation, change the number of neurons actually involved in the calculation, so as to realize the dynamic calculation and results at the component granularity; design dimension-related jump connections to realize structural variability at the layer granularity; specifically include the following contents: S1.

1. Partially inactivate a dimension of the weight within a layer through weight slicing technology to reduce the amount of calculation and change the feature dimension; the slicing operation acts on both the input and output dimensions; S1.2, increase the operation route in the model to change the depth, introduce skip connections, and replace the original module for calculation when performing skip layer operations; The jump connection described in S1.3 and S1.2 is related to the input and output configuration of the module. Based on the idea of ​​depthwise separable convolution, the features are compressed and aligned from different dimensions, and the input and output tensors of the module are classified into three categories according to the dimensions: one-dimensional data, two-dimensional data, and three-dimensional data. S1.

4. For 2D and 3D data, downsample the data through a pooling layer, and then use a convolutional layer with a kernel size of 1 to compress the information along the channel dimension. After reshaping the features, use two fully connected layers for feature fusion and dimension adjustment, and then reshape the intermediate features to align with the other dimensions of the module output besides the channel. Finally, use another convolutional layer with a kernel size of 1 to align their channel dimensions. S1.

5. For one-dimensional data, two fully connected layers are used to align their features. When the channel dimension of other dimensional data is 1, the input is directly flattened and treated as one-dimensional data. S2. Model calculation graph upgrade: Design a model calculation graph upgrade module, iteratively read the configuration of each part of the model according to the tree structure, schedule the corresponding dynamic components to re-assign values, and add jump connections to the feature extraction modules in the model according to the preset settings to reduce the calculation of unimportant modes; specifically include the following contents: S2.

1. The deep multimodal fusion network is considered as a tree structure, where the model index is the root index, the module is the child node, and the layer is the leaf node; S2.

2. For each module in the deep multimodal fusion network, first read the configuration of each base layer in the module, and replace the corresponding dynamic components according to the configuration definition; before replacement, the user selectively retains part of the static base layer; S2.

3. Perform different processing on the base layers at different locations to ensure that the reasoning function remains unchanged. Specifically: For the input layer of the module, the dynamic component used for replacement first reads the input channel dimension of the data, calculates the corresponding slice ratio with the component weight input dimension size, and completes the slicing along the input dimension; then, according to the proportional coefficient passed into the module, completes the slicing along the output dimension; for the static component that remains unchanged, the weight of the previous layer is only sliced ​​along the input dimension, and the weight of the next layer is only sliced ​​along the output dimension; For the output layer of the module, only slice along the input dimension; For other layers, their weights are sliced ​​in equal proportions in both dimensions according to the coefficients passed in by the module; S2.

4. Define jump connections with the same input and output configuration for the corresponding modules, and then regard the modules that have completed dynamic component replacement as a whole, form a dual-channel module side by side with the jump connection, and add the same gating design before and after the new module; when the proportional coefficient r=0 introduced into the module, that is, in the case of full slicing, the present invention activates the jump connection and deactivates the original module, and uses the jump connection to complete the reasoning; when the proportional coefficient r≠0, the original module is weighted sliced ​​to complete the reasoning; S3, dynamic multimodal model generation: first, the dynamic backbone is obtained by upgrading the original static model to provide the basis for reasoning; then, according to the defined number of compression strategies and the input settings of the multimodal model, the strategy network model is generated in combination with the set strategy network structure; finally, the strategy network and the dynamic backbone are spliced ​​to form a dynamic deep multimodal fusion network; the dynamic deep multimodal fusion network is divided into two steps during calculation: the strategy model accepts input to generate a structure adjustment strategy, and the dynamic backbone changes the structure according to the strategy and completes the reasoning; S4. Joint model training: Design a greedy strategy loss to guide strategy generation based on the change in prediction loss before and after the model structure changes; use knowledge distillation and joint training to improve the accuracy of the model, and rely on calculating penalty loss to improve the computational efficiency of the model.

2. The embedded online compression method for multimodal networks according to claim 1, characterized in that: The S3 specifically includes the following contents: S3.

1. Take multimodal samples as the input of the policy network, compress and extract the features of different modal parts respectively, and then modify the backbone network structure according to the spliced ​​feature generation structure adjustment strategy to achieve dynamic reasoning; S3.

2. Divide the data compression layer of the strategy network based on different modal tensor data, specifically: one-dimensional data , two-dimensional data and 3D data ; For one-dimensional data, the data compression layer is an input dimension a The output dimension is a / / p A fully connected layer, where / / represents integer division; for two-dimensional and three-dimensional data, the data compression layer is an input channel dimension a , the output channel dimension is 1, and the kernel size and stride are set to p The convolutional layer; S3.3, flatten the acquired features, use the independent fully connected layer with output dimension h1 of each branch to further extract features, and then concatenate them to get ,in h 2 indicates the number of branches; S3.4, use two fully connected layers as the decision part of the policy network and obtain ;in, N M Indicates the number of modules, K Indicates the number of strategy types; S3.5, use one-hot encoding to represent different compression strategies, and Argmax function Get the final strategy gout ; The policy network is jointly trained with the backbone network to learn how to make decisions automatically.

3. The embedded online compression method for multimodal networks according to claim 1, characterized in that: The S4 specifically includes the following contents: S4.

1. After generating the dynamic deep multimodal fusion network, by setting different structural adjustment strategies, running different subnets in the dynamic deep multimodal fusion network to obtain multiple outputs, so as to better train the various parts of the dynamic deep multimodal fusion network; Taking a dual-modal deep multimodal fusion network as an example, the model is based on X 0 and X 1 is input, B si , B di and B li They represent the output of the i-th module using skip connections, the output of the application generation strategy, and the output of the original module respectively; the output of running the multi-subnetwork is as follows: S4.1.

1. Run the original deep multimodal fusion network to get the output: Y l = B l2 ( B l0 ( X 0), B l1 ( X 1)) S4.1.

2. Activate all skip connections and run the smallest subnetwork to get the output: Y s = B s2 ( B s0 ( X 0), B s1 ( X 1)) S4.1.

3. Run the dynamic subnetwork of the application strategy network to generate the strategy and obtain the outputs respectively: Y d = B d2 ( B d0 ( X 0), B d1 ( X 1)) S4.1.

4. Activate the skip connections of each module independently and run the sub-network to obtain the following output: Y 0= B l2 ( B s0 ( X 0), B l1 ( X 1)) Y 1= B l2 ( B l0 ( X 0), B s1 ( X 1)) Y 2= B s2 ( B l0 ( X 0), B l1 ( X 1)) S4.1.

5. Calculate the prediction loss based on the multiple outputs obtained: L lce = CELoss ( Y l , Label ) L dce = CELoss ( Y d , Label ) L sce = CELoss ( Y s , Label ) in, CELoss (·) represents the cross entropy loss; S4.

2. Use knowledge distillation technology to transfer knowledge from the original model to improve the overall performance of the model. The specific function is expressed as: L lts = MSELoss ( Y s2 , Y l2 ) in, MSELoss (·) represents mean square error loss, Y s2 and Y l2 They represent the output features of the penultimate layer of the deep multimodal fusion network respectively; S4.

3. Design a greedy random loss to guide the policy network to generate a more favorable strategy: When the model contains N compressible modules and K types of compression strategies, by setting the compression strategy of one module to 0 and not compressing other modules, ACF generates a set of loss sequences L d =( d 0, d 1,…, d N-1 ); Run the model N times to get the label Y g =( g 0, g 1,…, g N-1 ) for policy network training: g i = random (0, K / 2-1)· ≥ L lce +random ( K / 2, K )· < L lce That is, when the module is compressed, if the loss decreases, it is regarded as a positive benefit, encouraging this compression strategy and generating a larger compression coefficient; otherwise, it is regarded as a negative benefit, suppressing this compression strategy and generating a smaller compression coefficient, thereby avoiding excessive information loss; S4.

4. Calculate the greedy random loss as follows: L g = CELoss ( Y g , Label ) The introduction of computational penalty loss enables the policy network to generate a lighter policy. The specific function is expressed as follows: in, SMACs (·) represents the computational effort of the dynamic deep multimodal fusion network after applying the generation strategy, K represents the computational effort of the original model, X represents the input, θ dynamic Indicates the weight involved in the calculation; S4.

5. Combining the contents of S4.1-S4.4, the total loss function applied in the training phase is expressed as follows: L total = L sce + L dce + L lce + L lts + L g + λ · L MAC in, λ Represents a number between 0 and 1, used to adjust the impact of the computational loss penalty; S4.

6. After training, the dynamic deep multimodal fusion network replaces the original model and is deployed locally on the device to participate in the reasoning task. During the reasoning stage, the dynamic deep multimodal fusion network first executes the strategy network to generate the structural adjustment strategy for all modules in the deep multimodal fusion network, and distributes it to the corresponding modules. Each module shares the same structural adjustment strategy, and different modules can use different adjustment strategies. Finally, the model completes the reasoning task of the input sample with a lightweight structure adjusted in real time.

Citation Information

Patent Citations

  • Method and device for slice deployment born by network arrangement layer of intelligent power grid

    CN110366193A

  • Dynamic face recognition method

    CN110991281A

  • Multimodal data inference

    US20230401479A1

  • KR20200083751A