Terminal-based model adaptation method, apparatus, device, and medium
By pruning the network layers of the initial model, the computational performance of different terminal devices is adapted, solving the stability and compatibility issues of artificial intelligence models on different terminal devices, and realizing efficient adaptation and data processing of models on different terminal devices.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- RICHFIT INFORMATION TECH
- Filing Date
- 2024-12-19
- Publication Date
- 2026-06-23
AI Technical Summary
Different terminal devices have poor stability and compatibility with artificial intelligence models, which makes it difficult for intelligent models to adapt and run across terminals, affecting data processing efficiency.
By acquiring terminal attribute information, the network layers in the initial model are pruned to remove unnecessary data channels, resulting in the target model. This target model is then packaged and delivered to the terminal device to adapt to the computing performance of different terminals.
This improved the model's adaptability to different terminal devices and data processing efficiency, ensuring seamless connection and collaboration of information between devices, and enhancing the efficiency and safety of oil and gas extraction.
Smart Images

Figure CN122264010A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of deep learning in the field of artificial intelligence, and more particularly to a terminal-based model adaptation method, apparatus, device and medium. Background Technology
[0002] With continuous economic development, the digital wave represented by technologies such as the Internet of Things, artificial intelligence, and big data is sweeping the globe. The development of oil and gas resources is facing shortcomings such as poor hazard identification capabilities, a lack of sound management mechanisms, and insufficient talent reserves and workforce development. It is necessary to leverage artificial intelligence technology to maximize the efficiency of production resource and factor utilization in oil and gas enterprise resource extraction and management, and to improve the ability to identify safety hazards.
[0003] However, the stability and compatibility of artificial intelligence models are poor across different terminal devices. As technology continues to be updated and iterated, cross-terminal adaptation and operation of intelligent models are becoming increasingly necessary.
[0004] Therefore, improving the accuracy and adaptability of intelligent models and enabling their deployment on different terminal devices is an urgent problem to be solved. Summary of the Invention
[0005] This application provides a terminal-based model adaptation method, apparatus, device, and medium to improve model adaptability and increase the efficiency of data processing on different terminals.
[0006] In a first aspect, embodiments of this application provide a terminal-based model adaptation method, comprising: obtaining a preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device;
[0007] Based on the attribute information of the terminal to be adapted, the network layer in the preset initial model is pruned to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer.
[0008] The target model is encapsulated and packaged to obtain a data packet of the target model, and the data packet of the target model is stored in the terminal to be adapted.
[0009] In one possible implementation, the network layer includes convolutional layers and batch normalized (BN) layers; based on the attribute information of the terminal to be adapted, the network layers in the preset initial model are pruned to obtain the target model, including:
[0010] Based on the attribute information of the terminal to be adapted, the convolutional layers in the preset initial model are pruned to obtain candidate models;
[0011] Based on the attribute information of the terminal to be adapted, the BN layer in the candidate model is pruned to obtain the target model.
[0012] In one possible implementation, based on the attribute information of the terminal to be adapted, the convolutional layers in the preset initial model are pruned to obtain a candidate model, including:
[0013] Based on the attribute information of the terminal to be adapted, the parameter range of the data channels in the convolutional layer is determined; wherein, the parameter range represents the numerical range of the weight parameters of the data channels in the convolutional layer, and each data channel in the convolutional layer has multiple weight parameters.
[0014] If the weight parameters of the data channels in the convolutional layer are not within the parameter range, then the weight parameters of the data channels in the convolutional layer are adjusted according to the parameter range to obtain the target parameters of the data channels in the convolutional layer; wherein, the target parameters represent the adjusted weight parameters;
[0015] Based on the target parameters of the data channels in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model.
[0016] In one possible implementation, the convolutional layers in the preset initial model are pruned according to the target parameters of the data channels in the convolutional layers to obtain the candidate model, including:
[0017] Based on the target parameters in each data channel of the convolutional layer, the norm of each data channel in the convolutional layer is determined; wherein, the norm is the sum of the absolute values of the target parameters in the data channel;
[0018] Based on the norm of each data channel in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model.
[0019] In one possible implementation, the convolutional layers in the preset initial model are pruned according to the norm of each data channel in the convolutional layer to obtain the candidate model, including:
[0020] Based on the norm of each data channel in the convolutional layer, the data channels in the convolutional layer are sorted to obtain a first sorting result;
[0021] Based on the preset first pruning ratio, the data channels to be pruned in the convolutional layer are determined from the first sorting results;
[0022] The data channels to be pruned in the convolutional layer are pruned to obtain the candidate model.
[0023] In one possible implementation, based on the attribute information of the terminal to be adapted, the BN layer in the candidate model is pruned to obtain the target model, including:
[0024] The second pruning ratio is determined based on the attribute information of the terminal to be adapted.
[0025] Obtain the scaling factor of each data channel in the BN layer of the candidate model, and obtain the preset factor threshold; wherein, the scaling factor characterizes the importance of the data channel in the BN layer, and each data channel in the BN layer corresponds to a scaling factor;
[0026] Based on the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio, the BN layer in the candidate model is pruned to obtain the target model.
[0027] In one possible implementation, the BN layer in the candidate model is pruned according to the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio to obtain the target model, including:
[0028] If the scaling factor of a data channel in the BN layer is less than the preset factor threshold, then the data channel in the BN layer is identified as a candidate channel.
[0029] Determine the proportion of the candidate channel to all data channels in the BN layer;
[0030] If the ratio is less than the second pruning ratio, then the candidate channel is determined as the data channel to be pruned in the BN layer;
[0031] The data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
[0032] In one possible implementation, it also includes:
[0033] If the ratio is equal to or greater than the second pruning ratio, then the data channels in the BN layer are sorted according to the scaling factor of each data channel in the BN layer to obtain a second sorting result;
[0034] Based on the second pruning ratio, determine the data channels to be pruned in the BN layer from the second sorting results;
[0035] The data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
[0036] In one possible implementation, it also includes:
[0037] If the scaling factors of the data channels in the BN layer are all equal to or greater than the preset factor threshold, then the candidate model is determined as the target model.
[0038] In one possible implementation, it also includes:
[0039] Obtain a preset validation set; wherein the preset validation set includes sample data required for model validation, used to validate the performance metrics of the target model;
[0040] Based on the preset validation set, determine the current performance metrics of the target model;
[0041] If the current performance metric meets the preset verification completion conditions, then the target model is packaged and packaged to obtain the data packet of the target model, and the data packet of the target model is stored in the terminal to be adapted.
[0042] Secondly, embodiments of this application provide a terminal-based model adaptation method apparatus, comprising:
[0043] An acquisition module is used to acquire a preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device.
[0044] The pruning module is used to prune the network layer in the preset initial model according to the attribute information of the terminal to be adapted, so as to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer.
[0045] The packaging module is used to encapsulate and package the target model to obtain a data packet of the target model, and store the data packet of the target model in the terminal to be adapted.
[0046] Thirdly, embodiments of this application provide a terminal-based model adaptation device, including: a memory and a processor;
[0047] The memory stores computer-executed instructions;
[0048] The processor executes computer execution instructions stored in the memory, causing the processor to perform the first aspect and / or various possible implementations of the first aspect as described above.
[0049] Fourthly, embodiments of this application provide a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, are used to implement the first aspect and / or various possible implementations of the first aspect.
[0050] Fifthly, embodiments of this application provide a computer program product, including a computer program that, when executed by a processor, implements the first aspect and / or various possible implementations of the first aspect.
[0051] This application provides a terminal-based model adaptation method, apparatus, device, and medium. First, a preset initial model and attribute information of the terminal to be adapted are obtained. The preset initial model includes at least two network layers, each with multiple data channels. The attribute information characterizes the computing performance of the terminal device. Second, based on the attribute information of the terminal to be adapted, the network layers in the preset initial model are pruned to obtain a target model. The pruning process reduces the number of data channels in the network layers. Finally, the target model is encapsulated and packaged to obtain a data packet, which is then stored in the terminal to be adapted. This solution improves the adaptability of the model across different terminals by obtaining an initial model, pruning it, and applying the target model to the terminal device, thereby increasing the efficiency of data processing across different terminals. Attached Figure Description
[0052] The accompanying drawings, which are incorporated in and form part of this specification, illustrate embodiments consistent with this application and, together with the description, serve to explain the principles of this application.
[0053] Figure 1 An overall architecture diagram of a terminal-based model adaptation method provided in this application;
[0054] Figure 2 A flowchart illustrating a terminal-based model adaptation method provided in this application;
[0055] Figure 3 A flowchart illustrating a terminal-based model adaptation method provided in this application;
[0056] Figure 4 A schematic diagram of a terminal-based model adaptation device provided in this application;
[0057] Figure 5 A schematic diagram of a terminal-based model adaptation device provided in this application;
[0058] Figure 6This is a schematic diagram of the structure of a terminal-based model adaptation device provided in this application.
[0059] The accompanying drawings illustrate specific embodiments of this application, which will be described in more detail below. These drawings and descriptions are not intended to limit the scope of the concept in any way, but rather to illustrate the concept of this application to those skilled in the art through reference to particular embodiments. Detailed Implementation
[0060] Exemplary embodiments will now be described in detail, examples of which are illustrated in the accompanying drawings. When the following description relates to the drawings, unless otherwise indicated, the same numbers in different drawings denote the same or similar elements. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with this application. Rather, they are merely examples of apparatuses and methods consistent with some aspects of this application as detailed in the appended claims.
[0061] With continuous economic development and the global digital wave represented by technologies such as the Internet of Things (IoT), artificial intelligence (AI), and big data, my country's oil and gas resource development is facing shortcomings such as poor hazard identification capabilities, a lack of sound management mechanisms, and insufficient talent reserves and workforce development. It is necessary to leverage IoT technology to maximize the efficiency of production resource and factor utilization in oil and gas enterprise resource extraction and management, and to improve the ability to identify safety hazards. Furthermore, domestically produced terminal equipment lags behind mainstream international brands, primarily due to weaker performance and poorer adaptability in domestic terminal and model design, especially lacking the technical means for stable compatibility and integration of intelligent models.
[0062] Although various fields have begun to strongly support cross-platform adaptation of models, it is still in its early stages. As technology continues to update and iterate, cross-platform adaptation and operation of intelligent models are becoming increasingly necessary.
[0063] Currently, traditional IoT in the oil and gas industry mainly focuses on equipment data collection, operation monitoring, and time-series data management within their respective business domains. Deeply integrating intelligent models with oilfield development, relying on management and technological innovation to improve the management level of oilfield production operations, and elevating IoT service scenarios to include comprehensive perception, real-time optimization, cloud-edge-device integration, and intelligent control across the entire oil and gas domain, is a pressing issue that needs to be addressed.
[0064] Based on the background technology described above, it can be seen that in the existing technology, the performance of the terminal and model design is relatively weak, the adaptability is poor, and in particular, there is a lack of technical means for the stability, compatibility, adaptation and integration of intelligent models.
[0065] This application provides a terminal-based model adaptation method, which relates to the field of deep learning in the field of artificial intelligence, and particularly to a terminal-based model adaptation method, device, equipment and medium, which aims to solve the above-mentioned technical problems of the prior art.
[0066] The technical solution of this application and how the technical solution of this application solves the above-mentioned technical problems are described in detail below with specific embodiments. These specific embodiments can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. The embodiments of this application will now be described with reference to the accompanying drawings.
[0067] Figure 1 This application provides an overall architecture diagram of a terminal-based model adaptation method; such as... Figure 1 As shown, the model quantization method mainly includes the following steps: First, collect the resource status of the terminal device, which includes constraints such as hardware capabilities and operating system. Hardware capabilities can include storage capacity, computing power, and power reserves. Second, during model quantization, the terminal's resource status can be obtained multiple times according to different situations. The model is trained through dynamic adaptive matching until the optimal quantization configuration is found. During dynamic adaptive training, the model can be adjusted according to the terminal hardware. Adjusting the model requires the support of the terminal hardware. A validation set is used to verify and provide feedback on the adjusted model. Finally, the verified model is deployed to the terminal device.
[0068] Figure 2 A flowchart illustrating a terminal-based model adaptation method provided in this application is shown below. Figure 2 As shown, the method includes:
[0069] S201. Obtain the preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device.
[0070] For example, attribute information characterizes the computing performance of the terminal device to be adapted. The computing performance of the terminal device may include information such as storage capacity, computing power, power reserves, and energy consumption. The initial model is a pre-trained basic model. The network layers in the initial model include at least two types of network layers: convolutional layers and batch normalization (BN) layers. Each network layer contains multiple data channels, where data channels refer to the output channels of the convolutional layers and the output channels of the BN layers.
[0071] The model's input channel is used to input data, and its output channel is used to output the processed data. Convolutional layers are used for feature extraction from data or images, while batch normalization layers are used for normalization. The target model, obtained by pruning the convolutional and batch normalization layers, can adapt to different terminal devices and run efficiently in various hardware and software environments.
[0072] For example, in oil extraction, real-time monitoring and optimization of the well production process are necessary to improve efficiency and safety. Sensors used to monitor oil fields may generate large amounts of time-series or image data. This data requires complex analysis to identify subsurface structures, predict equipment failures, or optimize production parameters. Furthermore, different users, such as field operators, remote engineers, and managers, may access and operate this data using various devices such as smartphones, tablets, and laptops.
[0073] After the sensors generate oilfield data, staff can process the data using a cross-terminal model on their terminals. First, the model acquires the oilfield data and extracts features from the data using a convolutional layer. Then, the output of the convolutional layer is input into a batch normalization layer for normalization, accelerating the model's processing and improving its stability. Finally, the data is uploaded to the cloud, allowing different staff to view the results using different terminal devices. This cross-terminal model enables all users to analyze and process data on their respective devices and access the analysis results in the cloud, ensuring information consistency and seamless connection and collaboration between different devices and users, thereby improving the efficiency and safety of the oil extraction process.
[0074] The advantage of this setup is that by using a preset initial model and processing the model according to the attribute information of the terminal to be adapted, the adaptability of the model to the terminal device can be improved.
[0075] S202. Based on the attribute information of the terminal to be adapted, the network layer in the preset initial model is pruned to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer.
[0076] For example, attribute information characterizes the computing performance of the terminal device to be adapted. This computing performance may include information such as the terminal device's storage capacity, computing power, power reserves, and energy consumption. Based on the attribute information of the terminal to be adapted, targeted pruning can be performed on the network layers in the initial model to obtain the target model corresponding to the terminal. For example, the attribute information can be used to determine how many networks or channels of network layers to prune from the initial model. For example, when the terminal attributes are poor, more network layers or channels can be pruned to improve the terminal's computing efficiency. The target models corresponding to each terminal to be adapted can be different.
[0077] The preset initial model includes at least two types of network layers: convolutional layers and batch normalization (BN) layers. Pruning is used to reduce the number of data channels in the network layers. For example, after obtaining the initial model and the attribute information of the terminal to be adapted, firstly, the weight parameters of each output channel in the convolutional layer are obtained. These weight parameters are pre-set model parameters, and each output channel has its own weight parameters. Based on the attribute information of the terminal device, a preset function `clamp` is used to filter the weight parameters; for example, smaller weight parameters can be removed. The norm of each output channel of the convolutional layer is calculated using the filtered weight parameters. The norm represents the importance of each output channel. The output channels of the convolutional layer are pruned according to the ranking of the norms and the pruning ratio. For example, a larger norm indicates a more important output channel. The pruning ratio can be pre-determined based on the terminal device's attribute information. For example, if the terminal device has poor computing power, a larger pruning ratio can be set, i.e., more weight parameters can be pruned, thereby reducing the computational load on the terminal device.
[0078] Secondly, the output channels of the Batch Normalization (BN) layer are pruned. The output of the convolutional layer serves as the input to the BN layer, which has a preset scaling factor, which is also a preset model parameter. The scaling factor represents the importance of the BN layer's output channels. The pruning ratio and scaling factor threshold of the BN layer are determined based on the terminal device's attribute information, and the output channels of the BN layer are pruned according to the scaling factor, pruning ratio, and threshold.
[0079] The advantage of this setup is that by pruning the convolutional and batch normalization (BN) layers, the complexity and computational cost of the model can be reduced, thus improving the model's adaptability to terminal devices.
[0080] In this embodiment, the convolutional layers in the preset initial model are pruned according to the attribute information of the terminal to be adapted, to obtain a candidate model; the BN layers in the candidate model are pruned according to the attribute information of the terminal to be adapted, to obtain the target model.
[0081] For example, the attribute information of the terminal to be adapted may include information such as the terminal device's storage capacity, computing power, power reserve, and energy consumption. Pruning is used to reduce the number of data channels in the network layer. For instance, firstly, based on the attribute information of the terminal device to be adapted, the pruning ratio of the convolutional layer is determined. This pruning ratio can be determined based on the attribute information of the terminal device; for example, for terminals with poor computing power and small memory, a larger pruning ratio can be set to reduce the computational load of the model. Next, the weight parameters of each output channel of the convolutional layer are obtained, and the norm of each output channel is calculated using these weight parameters. Each output channel in the convolutional layer contains multiple weight parameters. The output channels of the convolutional layer are sorted according to the magnitude of their norms; for example, a larger norm indicates a more important output channel. Based on the norm sorting and the pruning ratio, the output channels of the convolutional layer are reduced to obtain candidate models. Secondly, the scaling factor of the Batch Normalization (BN) layer is obtained. The scaling factor characterizes the importance of the BN layer's output channels and is a preset model parameter. Based on the attribute information of the terminal to be adapted, the pruning ratio of the BN layer and the threshold of the scaling factor are determined. For example, when the terminal to be adapted has poor computing performance and limited memory, a larger pruning ratio and threshold can be set to reduce the model's complexity and computational load. Finally, based on the pruning ratio and scaling factor threshold of the BN layer, the output channels of the BN layer are reduced to obtain the target model.
[0082] The advantage of this setup is that, based on the attribute information of the terminal to be adapted, the output channels of the convolutional layer and the BN layer are pruned sequentially, which facilitates the improvement of the model's adaptability to terminal devices.
[0083] In this embodiment, based on the attribute information of the terminal to be adapted, the convolutional layers in the preset initial model are pruned to obtain candidate models. This includes: determining the parameter range of the data channels in the convolutional layers based on the attribute information of the terminal to be adapted; wherein, the parameter range represents the numerical range of the weight parameters of the data channels in the convolutional layers, and each data channel in the convolutional layers corresponds to multiple weight parameters; if the weight parameters of the data channels in the convolutional layers are not within the parameter range, the weight parameters of the data channels in the convolutional layers are adjusted according to the parameter range to obtain the target parameters of the data channels in the convolutional layers; wherein, the target parameters represent the adjusted weight parameters; and pruning the convolutional layers in the preset initial model based on the target parameters of the data channels in the convolutional layers to obtain candidate models.
[0084] For example, the attribute information of the terminal to be adapted may include information such as the terminal device's storage capacity, computing power, power reserve, and energy consumption. Pruning is used to reduce the number of data channels in the network layer. The parameter range represents the numerical range of the weight parameters of the data channels in the convolutional layer; each data channel in the convolutional layer corresponds to multiple weight parameters. The target parameter represents the adjusted weight parameters. For example, after obtaining the preset initial model and the attribute information of the terminal to be adapted, before pruning the output channels of the convolutional layer, the weight parameters of each output channel of the convolutional layer are first obtained. Based on the attribute information of the terminal to be adapted, the parameter range of the output channel weight parameters is determined. For example, when the terminal to be adapted has limited memory and poor computing power, a smaller weight parameter range can be set, thereby reducing the computational load of the model and improving the model's adaptability to the terminal. The preset function `clamp` is used to filter the weight parameters. Each output channel of the convolutional layer contains multiple weight parameters; if a weight parameter is not within the determined parameter range, the weight parameter is adjusted. For example, if the weight parameters range from 0 to 10, and the weight parameters of the output channel include -1 and 11, then the -1 and 11 weight parameters are adjusted to 0 and 10 respectively to obtain the adjusted weight parameters, which are the target parameters of the output channel in the convolutional layer.
[0085] The advantage of this setting is that, based on the attribute information of the terminal to be adapted, the weight parameters of the output channel of the convolutional layer are controlled within a preset range, which makes it easier to improve the adaptability of the model to the terminal to be adapted.
[0086] In this embodiment, the convolutional layers in the preset initial model are pruned according to the target parameters of the data channels in the convolutional layers to obtain candidate models. This includes: determining the norm of each data channel in the convolutional layer according to the target parameters in each data channel; wherein the norm is the sum of the absolute values of the target parameters in the data channels; and pruning the convolutional layers in the preset initial model according to the norms of each data channel in the convolutional layer to obtain candidate models.
[0087] For example, the target parameters represent the weight parameters of the adjusted output channels of the convolutional layer, and the pruning process is used to reduce the number of data channels in the network layer. For instance, after obtaining the attribute information of the preset initial model and the terminal to be adapted, the weight parameters of each output channel of the convolutional layer are filtered out to determine the target parameters. Each output channel of the convolutional layer contains multiple weight parameters. Based on each target parameter, the norm of each output channel of the convolutional layer is calculated, where the norm is the sum of the absolute values of the target parameters in each output channel of the convolutional layer, and the norm represents the importance of each output channel of the convolutional layer. The norms of each output channel in the convolutional layer are sorted to determine the importance of each output channel. For example, the larger the norm, the more important the output channel. Based on the sorting results of the norms and the preset pruning ratio, the convolutional layers of the initial model are pruned to obtain candidate models.
[0088] The advantage of this setup is that by calculating the norm of each output channel of the convolutional layer, the model can be pruned, making it easier to assess the importance of each output channel and improving the accuracy of the model.
[0089] In this embodiment, the convolutional layer in the preset initial model is pruned according to the norm of each data channel in the convolutional layer to obtain a candidate model. This includes: sorting each data channel in the convolutional layer according to the norm of each data channel in the convolutional layer to obtain a first sorting result; determining the data channels to be pruned in the convolutional layer from the first sorting result according to a preset first pruning ratio; and pruning the data channels to be pruned in the convolutional layer to obtain a candidate model.
[0090] For example, pruning is used to reduce the number of data channels in a network layer. The norm represents the importance of each output channel of the convolutional layer. The norm of each output channel is the sum of the absolute values of the weight parameters in that output channel, and each output channel contains multiple weight parameters. For example, based on the range of weight parameters, after filtering out the weight parameters of the convolutional layer, target parameters are obtained. The range of weight parameters is determined based on the attribute information of the device to be adapted. For example, if the computing power of the terminal to be adapted is poor, the computational load of the model can be reduced by decreasing the weight parameters. After obtaining the target parameters for each output channel of the convolutional layer, the sum of the absolute values of the weight parameters of each output channel is calculated, i.e., the norm. The norm represents the importance of the output channel of the convolutional layer. The calculated norms of each output channel are sorted to obtain a first sorting result. Based on the first sorting result and a preset first pruning ratio, the output channels of the convolutional layer are reduced to obtain candidate models. The first pruning ratio can be determined based on the attribute information of the terminal to be adapted. For example, for terminals with small memory, a larger pruning ratio can be set to reduce the complexity and computation of the model and improve the adaptability of the model to the terminal to be adapted.
[0091] The advantage of this setup is that by calculating the norm based on the weight parameters of the convolutional layer output channels and sorting the norms, it is easier to determine the importance ranking of the convolutional layer output channels, avoid the deletion of important output channels, and improve the accuracy of the model.
[0092] In this embodiment, the BN layer in the candidate model is pruned according to the attribute information of the terminal to be adapted to obtain the target model. This includes: determining a second pruning ratio based on the attribute information of the terminal to be adapted; obtaining the scaling factor of each data channel in the BN layer of the candidate model, and obtaining a preset factor threshold; wherein the scaling factor represents the importance of the data channel in the BN layer, and each data channel in the BN layer corresponds to a scaling factor; and pruning the BN layer in the candidate model according to the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio to obtain the target model.
[0093] For example, the attribute information of the terminal to be adapted may include information such as the terminal device's storage capacity, computing power, power reserve, and energy consumption. Pruning is used to reduce the number of data channels in the network layer. The scaling factor characterizes the importance of the data channels in the BN layer. First, based on the attribute information of the terminal device to be adapted, the pruning ratio of the BN layer, i.e., the second pruning ratio, is determined. For example, for terminal devices with small memory, a larger pruning ratio can be set to reduce the complexity and computational load of the model, thereby improving the model's adaptability to the terminal to be adapted. Second, the BN layer has a preset scaling factor, which is a preset model parameter. The scaling factor and factor threshold of each output channel in the BN layer are obtained. In this model, each output channel in the Batch Normalization (BN) layer corresponds to a scaling factor. The factor threshold can be set according to the attribute information of the terminal to be adapted and the performance requirements of the specific application scenario. For example, when scaling factors are 5, 6, 7, 8, and 9, if the performance requirement is 90% accuracy, the factor threshold can be set to 7, resulting in lower model computation and complexity. If the performance requirement is 95%, the factor threshold can be set to 6, resulting in higher model complexity and computation. The absolute values of the scaling factors are sorted; for example, the larger the value, the more important the output channel of the BN layer. Finally, based on the sorting results of the scaling factors, the pruning ratio, and the factor threshold, the output channels of the BN layer are reduced to obtain the target model.
[0094] The advantage of this setup is that, based on the attribute information of the terminal to be adapted, the BN layer is pruned according to the scaling factor, pruning ratio, and factor threshold, which makes it easier to retain the important channels of the BN layer and improve the accuracy and adaptability of the model.
[0095] In this embodiment, the BN layer in the candidate model is pruned according to the scaling factor of each data channel in the BN layer, a preset factor threshold, and a second pruning ratio to obtain the target model. This includes: if the scaling factor of a data channel in the BN layer is less than the preset factor threshold, then the data channel in the BN layer is identified as a candidate channel; the proportion of the candidate channel to all data channels in the BN layer is determined; if the proportion is less than the second pruning ratio, the candidate channel is identified as a data channel to be pruned in the BN layer; and the data channel to be pruned in the BN layer of the candidate model is pruned to obtain the target model.
[0096] For example, pruning is used to reduce the number of data channels in a network layer. The scaling factor characterizes the importance of a data channel in the BN layer, and each output channel in the BN layer corresponds to a scaling factor. When pruning the output channels of the BN layer, if the scaling factor of an output channel is less than a preset factor threshold, the output channel corresponding to the scaling factor less than the factor threshold is identified as a channel to be pruned, i.e., a candidate channel. The proportion of this candidate channel to the total output channels of the BN layer is determined. If this proportion is less than the second pruning proportion of the BN layer output channels, the output channel is pruned according to this proportion. For example, the scaling factors are 5, 6, 7, 8, and 9, the preset factor threshold is 6, and the second pruning proportion is 30%. A scaling factor less than the factor threshold of 6 is determined to be 5, and the corresponding output channel accounts for 20% of the total output channels of the BN layer. Therefore, the output channels of the BN layer are pruned according to a 20% proportion.
[0097] The advantage of this setup is that it makes it easier to avoid pruning the important output channels of the BN layer, thereby improving the accuracy and adaptability of the model.
[0098] In this embodiment, the method further includes: if the ratio is equal to or greater than the second pruning ratio, sorting the data channels in the BN layer according to the scaling factor of each data channel in the BN layer to obtain a second sorting result; determining the data channels to be pruned in the BN layer from the second sorting result according to the second pruning ratio; and pruning the data channels to be pruned in the BN layer of the candidate model to obtain the target model.
[0099] For example, pruning is used to reduce the number of data channels in a network layer. The scaling factor characterizes the importance of data channels in the BN layer, and each output channel in the BN layer corresponds to a scaling factor. For instance, when pruning a BN layer, if the scaling factor of an output channel is less than a preset factor threshold, the output channel corresponding to the scaling factor less than the factor threshold is identified as a channel to be pruned, i.e., a candidate channel, and the proportion of this channel to the total output channels of the BN layer is determined. If this proportion is greater than or equal to the second pruning proportion of the BN layer output channels, the absolute value sorting order of the scaling factors is determined, i.e., the second sorting result. The output channels of the BN layer are pruned according to a preset pruning proportion. For example, the scaling factors are 5, 6, 7, 8, and 9, the preset factor threshold is 6, and the preset second pruning proportion is 10%. A scaling factor less than the factor threshold of 6 is 5, and its corresponding output channel accounts for 20% of the total output channels of the BN layer. This proportion is greater than the preset second pruning proportion, so the output channels of the BN layer are pruned at a rate of 10%.
[0100] The advantage of this setting is that the output channels of the BN layer are reduced according to the scaling factor, factor threshold, and pruning ratio, which helps to reduce model complexity and computational load, and improve the accuracy and adaptability of the model.
[0101] In this embodiment, the method further includes: if the scaling factors of the data channels in the BN layer are all equal to or greater than a preset factor threshold, then the candidate model is determined as the target model.
[0102] For example, when pruning the output channels of the BN layer, if the scaling factors of all output channels of the BN layer are greater than a preset factor threshold, then no pruning is performed on the output channels of the BN layer. The factor threshold can be determined based on the attribute information of the terminal to be adapted and the performance requirements of the specific application scenario. For example, when the terminal to be adapted has limited memory and poor computing power, a larger factor threshold can be set to prune more BN layer output channels, reducing the complexity and computational load of the model. For example, the scaling factors are 5, 6, 7, 8, and 9, and the preset factor threshold is 4. If no scaling factors less than the factor threshold 4 are found, it indicates that the output channels corresponding to the scaling factors of that BN layer are all important. In this case, no pruning is performed on the output channels of the BN layer, and the candidate model is determined as the target model. The candidate model is the model after pruning the output channels of the convolutional layer.
[0103] The advantage of this setup is that it avoids removing the more important output channels of the BN layer, thus improving the model's adaptability to different terminals.
[0104] S203. Encapsulate and package the target model to obtain the target model data packet, and store the target model data packet in the terminal to be adapted.
[0105] For example, attribute information characterizes the computing performance of the terminal device to be adapted, which may include information such as the terminal device's storage capacity, computing power, power reserves, and energy consumption. Pruning is used to reduce data channels in the network layers. For example, after obtaining the initial model and the attribute information of the terminal to be adapted, pruning is performed on the output channels of the convolutional layer and the output channels of the Batch Normalization (BN) layer to obtain the target model. A preset validation set is provided, which includes sample data required for model validation to verify the performance indicators of the target model. The performance indicators of the target model may include accuracy, precision, recall, speed, and resource consumption. The target model is validated using the preset validation set. The validation method may be to compare the performance of the target model and the initial model using the validation set. If the target model's performance is improved compared to the initial model, the validation condition is met. Alternatively, the target model may be iteratively processed using the validation set until the performance indicators of the obtained model reach the best effect, then the validation condition is met. During iterative processing, the pruning ratio and factor threshold can be adaptively adjusted based on the attribute information of the terminal to be adapted and the requirements of the specific application scenario. For example, when the terminal to be adapted has limited memory and poor computing power, a larger pruning ratio and factor threshold can be set to prune more output channels, thereby reducing model complexity and computational load. Finally, the target model validated using the validation set is packaged and the packaged data packet is installed into the terminal device to be adapted.
[0106] The advantage of this setup is that using a validation set to validate the target model helps it achieve optimal performance and improves its adaptability.
[0107] This application provides a terminal-based model adaptation method, apparatus, device, and medium. First, a preset initial model and attribute information of the terminal to be adapted are obtained. The preset initial model includes at least two network layers, each with multiple data channels. The attribute information characterizes the computing performance of the terminal device. Second, based on the attribute information of the terminal to be adapted, the network layers in the preset initial model are pruned to obtain a target model. The pruning process reduces the number of data channels in the network layers. Finally, the target model is encapsulated and packaged to obtain a data packet, which is then stored in the terminal to be adapted. This solution improves the adaptability of the model across different terminals by obtaining an initial model, pruning it, and applying the target model to the terminal device, thereby increasing the efficiency of data processing across different terminals.
[0108] Figure 3 A flowchart illustrating a terminal-based model adaptation method provided in this application is shown below. Figure 3 As shown, in this embodiment... Figure 2 Based on the embodiments, a terminal-based model adaptation method is described in detail, which includes:
[0109] S301. Obtain the preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device.
[0110] For example, this step can refer to step S201 above, and will not be repeated here.
[0111] S302. Based on the attribute information of the terminal to be adapted, the network layer in the preset initial model is pruned to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer.
[0112] For example, this step can refer to step S202 above, and will not be repeated here.
[0113] S303. Obtain a preset validation set; wherein, the preset validation set includes sample data required for model validation, used to validate the performance metrics of the target model.
[0114] For example, the pre-defined validation set includes sample data required for model validation, used to verify the performance metrics of the target model. The performance metrics of the target model may include accuracy, precision, recall, speed, resource consumption, etc. A pre-defined validation set is provided, and the data from this set is input into the pruned target model. The performance of the target model is then validated using this validation set. The validation method can be determined based on the specific application scenario requirements or by comparing the performance of the target model with the initial model. For example, when the performance requirement is 96% accuracy, the model is updated by adjusting the pruning ratio and threshold until the performance of the resulting model meets the requirements; at this point, the validation completion condition is determined.
[0115] The advantage of this setup is that it allows for performance validation of the target model using a validation set, which helps improve the model's accuracy.
[0116] S304. If the current performance indicators meet the preset verification completion conditions, then the target model is packaged and packaged to obtain the target model data packet, and the target model data packet is stored in the terminal to be adapted.
[0117] For example, a validation set is pre-set, containing sample data required for model validation. This set is used to verify the performance metrics of the target model, which may include accuracy, precision, recall, speed, and resource consumption. Validation completion conditions can be pre-set according to specific application scenarios; alternatively, the performance of the target model can be compared with that of the initial model using the validation set. If the target model's performance improves, the validation completion condition is met; or the target model can be iteratively updated by adjusting the pruning ratio and factor thresholds until the best-performing target model is obtained, which also satisfies the validation completion condition. After inputting the data from the validation set into the target model for validation, if the obtained performance metrics meet the pre-set validation completion conditions, the target model is packaged and the packaged data packet is stored in the terminal device to be adapted. If the pre-set validation completion conditions are not met, the model continues to be iteratively processed, and the pruning ratio and factor thresholds can be adjusted to optimize the model's performance metrics.
[0118] The advantage of this setup is that it allows for the verification of the target model, and the verified target model is packaged and stored in the terminal to be adapted, which facilitates the improvement of the model's accuracy and adaptability.
[0119] This application provides a terminal-based model adaptation method, apparatus, device, and medium. First, a preset initial model and attribute information of the terminal to be adapted are obtained. The preset initial model includes at least two network layers, each with multiple data channels. The attribute information characterizes the computing performance of the terminal device. Second, based on the attribute information of the terminal to be adapted, the network layers in the preset initial model are pruned to obtain a target model. The pruning process reduces the number of data channels in the network layers. Finally, the target model is encapsulated and packaged to obtain a data packet, which is then stored in the terminal to be adapted. This solution improves the adaptability of the model across different terminals by obtaining an initial model, pruning it, and applying the target model to the terminal device, thereby increasing the efficiency of data processing across different terminals.
[0120] Figure 4 A schematic diagram of a terminal-based model adaptation device provided in this application is shown below. Figure 4 As shown, the terminal-based model adaptation method apparatus 400 provided in this embodiment includes:
[0121] The acquisition module 401 is used to acquire a preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device.
[0122] The pruning module 402 is used to prune the network layer in the preset initial model according to the attribute information of the terminal to be adapted, so as to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer.
[0123] The packaging module 403 is used to encapsulate and package the target model to obtain a data packet of the target model, and store the data packet of the target model in the terminal to be adapted.
[0124] Figure 5 A schematic diagram of a terminal-based model adaptation device provided in this application is shown below. Figure 5 As shown, the device 500 includes an acquisition module 501, a pruning module 502, and a packaging module 503. The pruning module 502 includes a first pruning unit 5021 and a second pruning unit 5022, and the packaging module 503 includes a determination unit 5031 and a packaging unit 5032.
[0125] In one example, pruning module 502 includes:
[0126] The first pruning unit 5021 is used to prune the convolutional layers in the preset initial model based on the attribute information of the terminal to be adapted, so as to obtain a candidate model.
[0127] The second pruning unit 5022 is used to prune the BN layer in the candidate model according to the attribute information of the terminal to be adapted, so as to obtain the target model.
[0128] In one example, the first pruning unit 5021 includes:
[0129] The first determining subunit is used to determine the parameter range of the data channels in the convolutional layer based on the attribute information of the terminal to be adapted; wherein the parameter range represents the numerical range of the weight parameters of the data channels in the convolutional layer, and each data channel in the convolutional layer corresponds to multiple weight parameters.
[0130] An adjustment subunit is configured to adjust the weight parameters of the data channels in the convolutional layer according to the parameter range if the weight parameters of the data channels in the convolutional layer are not within the parameter range, thereby obtaining the target parameters of the data channels in the convolutional layer; wherein the target parameters represent the adjusted weight parameters.
[0131] The first pruning subunit is used to prune the convolutional layer in the preset initial model according to the target parameters of the data channels in the convolutional layer, so as to obtain the candidate model.
[0132] In one example, the pruning subunit is specifically used for:
[0133] Based on the target parameters in each data channel of the convolutional layer, the norm of each data channel in the convolutional layer is determined; wherein, the norm is the sum of the absolute values of the target parameters in the data channels; based on the norm of each data channel in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model.
[0134] In one example, the pruning subunit is specifically used for:
[0135] Based on the norm of each data channel in the convolutional layer, the data channels in the convolutional layer are sorted to obtain a first sorting result; based on a preset first pruning ratio, the data channels to be pruned in the convolutional layer are determined from the first sorting result; the data channels to be pruned in the convolutional layer are pruned to obtain the candidate model.
[0136] In one example, the second pruning unit 5022 includes:
[0137] The second determining subunit is used to determine the second pruning ratio based on the attribute information of the terminal to be adapted;
[0138] The acquisition subunit is used to acquire the scaling factor of each data channel in the BN layer of the candidate model, and to acquire a preset factor threshold; wherein, the scaling factor characterizes the importance of the data channel in the BN layer, and each data channel in the BN layer corresponds to a scaling factor;
[0139] The second pruning subunit is used to prune the BN layer in the candidate model according to the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio, so as to obtain the target model.
[0140] In one example, the second pruning subunit is specifically used for:
[0141] If the scaling factor of a data channel in the BN layer is less than the preset factor threshold, then the data channel in the BN layer is identified as a candidate channel; the proportion of the candidate channel to all data channels in the BN layer is determined; if the proportion is less than the second pruning ratio, then the candidate channel is identified as a data channel to be pruned in the BN layer; the data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
[0142] In one example, the second pruning subunit is specifically used for:
[0143] If the ratio is equal to or greater than the second pruning ratio, then the data channels in the BN layer are sorted according to the scaling factor of each data channel in the BN layer to obtain a second sorting result; according to the second pruning ratio, the data channels to be pruned in the BN layer are determined from the second sorting result; the data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
[0144] In one example, the second pruning subunit is specifically used for:
[0145] If the scaling factors of the data channels in the BN layer are all equal to or greater than the preset factor threshold, then the candidate model is determined as the target model.
[0146] In one example, package module 503 includes:
[0147] The determining unit 5031 is used to determine the current performance index of the target model based on the preset verification set;
[0148] Packaging unit 5032 is used to perform the packaging process of the target model to obtain the data packet of the target model if the current performance index meets the preset verification completion conditions, and to store the data packet of the target model in the terminal to be adapted.
[0149] This embodiment provides a terminal-based model adaptation method device that can execute the method provided in the above-described method embodiments. Its implementation principle and technical effects are similar, and will not be described in detail here.
[0150] Figure 6 This is a schematic diagram of the structure of a terminal-based model adaptation device provided in this application. Figure 6 As shown, the electronic device 600 provided in this embodiment includes at least one processor 601 and a memory 602. Optionally, the device 600 further includes a communication component 603. The processor 601, memory 602, and communication component 603 are connected via a bus 604.
[0151] In a specific implementation, at least one processor 601 executes computer execution instructions stored in memory 602, causing at least one processor 601 to perform the above-described method.
[0152] The specific implementation process of processor 601 can be found in the above method embodiments, and its implementation principle and technical effect are similar. It will not be repeated here.
[0153] In the above embodiments, it should be understood that the processor can be a Central Processing Unit (CPU), or other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), etc. The general-purpose processor can be a microprocessor or any conventional processor. The steps of the method disclosed in this invention can be directly implemented by a hardware processor, or implemented by a combination of hardware and software modules within the processor.
[0154] The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage device.
[0155] The bus can be an Industry Standard Architecture (ISA) bus, a Peripheral Component Interconnect (PCI) bus, or an Extended Industry Standard Architecture (EISA) bus, etc. Buses can be categorized as address buses, data buses, control buses, etc. For ease of illustration, the buses shown in the accompanying drawings are not limited to a single bus or a single type of bus.
[0156] This application also provides a computer program product, including a computer program that, when executed by a processor, implements the above-described method.
[0157] This application also provides a computer-readable storage medium storing computer-executable instructions, which, when executed by a processor, implement the above-described method.
[0158] The aforementioned readable storage medium can be implemented by any type of volatile or non-volatile storage device or a combination thereof, such as static random access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic storage, flash memory, magnetic disk, or optical disk. The readable storage medium can be any available medium accessible to a general-purpose or special-purpose computer.
[0159] An exemplary readable storage medium is coupled to a processor, enabling the processor to read information from and write information to the readable storage medium. Of course, the readable storage medium can also be a component of the processor. The processor and the readable storage medium can reside in an Application Specific Integrated Circuit (ASIC). Alternatively, the processor and the readable storage medium can exist as discrete components in the device.
[0160] The division of units is merely a logical functional division; in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be indirect coupling or communication connection through some interfaces, devices, or units, and may be electrical, mechanical, or other forms.
[0161] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0162] In addition, the functional units in the various embodiments of the present invention can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0163] If a function is implemented as a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) to execute all or part of the steps of the methods of the various embodiments of this invention. The aforementioned storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0164] Those skilled in the art will understand that all or part of the steps of the above-described method embodiments can be implemented by hardware related to program instructions. The aforementioned program can be stored in a computer-readable storage medium. When executed, the program performs the steps of the above-described method embodiments; and the aforementioned storage medium includes various media capable of storing program code, such as ROM, RAM, magnetic disks, or optical disks.
[0165] Finally, it should be noted that other embodiments of the invention will readily occur to those skilled in the art upon consideration of the specification and practice of the invention disclosed herein. This invention is intended to cover any variations, uses, or adaptations of the invention that follow the general principles of the invention and include common knowledge or customary techniques in the art not disclosed herein, and is not limited to the precise structures described above and shown in the accompanying drawings, and various modifications and changes can be made without departing from its scope. The scope of the invention is limited only by the appended claims.
Claims
1. A terminal-based model adaptation method, characterized in that, include: Obtain a preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device; Based on the attribute information of the terminal to be adapted, the network layer in the preset initial model is pruned to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer. The target model is encapsulated and packaged to obtain a data packet of the target model, and the data packet of the target model is stored in the terminal to be adapted.
2. The method according to claim 1, characterized in that, The network layers include convolutional layers and batch normalized (BN) layers; based on the attribute information of the terminal to be adapted, the network layers in the preset initial model are pruned to obtain the target model, including: Based on the attribute information of the terminal to be adapted, the convolutional layers in the preset initial model are pruned to obtain candidate models; Based on the attribute information of the terminal to be adapted, the BN layer in the candidate model is pruned to obtain the target model.
3. The method according to claim 2, characterized in that, Based on the attribute information of the terminal to be adapted, the convolutional layers in the preset initial model are pruned to obtain candidate models, including: Based on the attribute information of the terminal to be adapted, the parameter range of the data channels in the convolutional layer is determined; wherein, the parameter range represents the numerical range of the weight parameters of the data channels in the convolutional layer, and each data channel in the convolutional layer has multiple weight parameters. If the weight parameters of the data channels in the convolutional layer are not within the parameter range, then the weight parameters of the data channels in the convolutional layer are adjusted according to the parameter range to obtain the target parameters of the data channels in the convolutional layer; wherein, the target parameters represent the adjusted weight parameters; Based on the target parameters of the data channels in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model.
4. The method according to claim 3, characterized in that, Based on the target parameters of the data channels in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model, including: Based on the target parameters in each data channel of the convolutional layer, the norm of each data channel in the convolutional layer is determined; wherein, the norm is the sum of the absolute values of the target parameters in the data channel; Based on the norm of each data channel in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model.
5. The method according to claim 4, characterized in that, Based on the norm of each data channel in the convolutional layer, the convolutional layers in the preset initial model are pruned to obtain the candidate model, including: Based on the norm of each data channel in the convolutional layer, the data channels in the convolutional layer are sorted to obtain a first sorting result; Based on the preset first pruning ratio, the data channels to be pruned in the convolutional layer are determined from the first sorting results; The data channels to be pruned in the convolutional layer are pruned to obtain the candidate model.
6. The method according to any one of claims 2-5, characterized in that, Based on the attribute information of the terminal to be adapted, the Batch Normalization (BN) layer in the candidate model is pruned to obtain the target model, including: The second pruning ratio is determined based on the attribute information of the terminal to be adapted. Obtain the scaling factor of each data channel in the BN layer of the candidate model, and obtain the preset factor threshold; wherein, the scaling factor characterizes the importance of the data channel in the BN layer, and each data channel in the BN layer corresponds to a scaling factor; Based on the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio, the BN layer in the candidate model is pruned to obtain the target model.
7. The method according to claim 6, characterized in that, Based on the scaling factor of each data channel in the BN layer, the preset factor threshold, and the second pruning ratio, the BN layer in the candidate model is pruned to obtain the target model, including: If the scaling factor of a data channel in the BN layer is less than the preset factor threshold, then the data channel in the BN layer is identified as a candidate channel. Determine the proportion of the candidate channel to all data channels in the BN layer; If the ratio is less than the second pruning ratio, then the candidate channel is determined as the data channel to be pruned in the BN layer; The data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
8. The method according to claim 7, characterized in that, Also includes: If the ratio is equal to or greater than the second pruning ratio, then the data channels in the BN layer are sorted according to the scaling factor of each data channel in the BN layer to obtain a second sorting result; Based on the second pruning ratio, determine the data channels to be pruned in the BN layer from the second sorting results; The data channels to be pruned in the BN layer of the candidate model are pruned to obtain the target model.
9. The method according to claim 8, characterized in that, Also includes: If the scaling factors of the data channels in the BN layer are all equal to or greater than the preset factor threshold, then the candidate model is determined as the target model.
10. The method according to claim 1, characterized in that, Also includes: Obtain a preset validation set; wherein the preset validation set includes sample data required for model validation, used to validate the performance metrics of the target model; Based on the preset validation set, determine the current performance metrics of the target model; If the current performance metric meets the preset verification completion conditions, then the target model is packaged and packaged to obtain the data packet of the target model, and the data packet of the target model is stored in the terminal to be adapted.
11. A terminal-based model adaptation method apparatus, characterized in that, include: An acquisition module is used to acquire a preset initial model and attribute information of the terminal to be adapted; wherein, the preset initial model includes at least two network layers, each network layer has multiple preset data channels, and the attribute information characterizes the computing performance of the terminal device. The pruning module is used to prune the network layer in the preset initial model according to the attribute information of the terminal to be adapted, so as to obtain the target model; wherein, the pruning process is used to reduce the data channels in the network layer. The packaging module is used to encapsulate and package the target model to obtain a data packet of the target model, and store the data packet of the target model in the terminal to be adapted.
12. A terminal-based model adaptation device, characterized in that, include: Memory, processor; The memory stores computer-executed instructions; The processor executes computer execution instructions stored in the memory, causing the processor to perform the method as described in any one of claims 1-10.
13. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when executed by a processor, are used to implement the method as described in any one of claims 1-10.
14. A computer program product, characterized in that, Includes a computer program that, when executed by a processor, implements the method described in any one of claims 1-10.