Lightweight embedded implementation mechanism of Rogowski coil interphase interference compensation MFNN method
By applying the MFNN method of multi-task learning in Roche coils, the problem of degradation of measurement accuracy in Roche coils in multi-phase systems is solved, efficient interphase interference compensation and lightweight embedded implementation are achieved, and measurement accuracy and system real-time performance are improved.
Patent Information
- Application Number
- CN202411596674.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-11-11
- Publication Date
- 2025-02-28
AI Technical Summary
In a multiphase system, the Roche coil produces phase interference due to the electromagnetic coupling effect between phase lines, resulting in a decrease in measurement accuracy.
The MFNN method adopts the multi-task learning idea, by training a multi-branch fully connected neural network model, compensates for the interphase interference of the Roche coil, and lightens the model to achieve embedded implementation.
It improves the current measurement accuracy of Rochester coils, realizes real-time compensation in the edge computing environment, reduces delays and improves the real-time and safety of the system.
Smart Images

Figure CN119538990A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of current measurement, and in particular to a lightweight embedded implementation mechanism of a Rogowski coil interphase interference compensation MFNN method. Background Art
[0002] Rogowski coil is an AC current sensor, a hollow ring coil, which is flexible or rigid. It can be directly put on the conductor to measure AC current. Since Rogowski coil is easy to install, does not need to be powered off, and has little physical interference to the equipment, it is widely used in industrial production. However, the measurement accuracy of Rogowski coil is low, especially when it is used in a multi-phase system, it will produce phase interference due to the electromagnetic coupling effect between the phase lines, resulting in a decrease in measurement accuracy. The phase interference compensation method based on MFNN refers to collecting three-phase current data at different phase distances, training to obtain parameters, so that MFNN compensates for the difference between the original measurement value and the nominal value of the Rogowski coil, and improves the final current measurement accuracy. The key to the application of this method in actual production is its lightweight embedded implementation. The embedded system itself has the characteristics of small size, low power consumption, and high integration, and has been widely used in intelligent manufacturing, industrial control, aerospace, education and medical care and other fields. Patent CN116540990A provides a code integration method and device based on embedded implementation of electronic products to solve the problem of low efficiency of embedded code integration method. Patent CN107860312A provides an embedded implementation system and method for a structured light three-dimensional measurement algorithm, solving the problem that existing optical measurement methods are difficult to integrate into industrial sites.
[0003] The above-mentioned specific patent comparative documents are:
[0004] 1) "A structured light measurement method and system for correcting measurement errors based on deep learning", patent number CN117036453A, this patent discloses a structured light measurement method and system for correcting measurement errors based on deep learning. First, an error prediction model of an optical measuring instrument is constructed based on a computer deep learning method, and then the error compensation coefficient of the optical measuring instrument is determined, and the optical measuring instrument is used to measure the object to be measured to obtain optical measurement data, and then the optical measurement data is input into the error prediction model to obtain the error prediction value, and the error value is used as training data to train the computer deep learning model, and the computer deep learning model is used to predict the errors generated in the measurement process and compensate for them, thereby achieving high-precision measurement. The MFNN method of the present invention is different from the above, adopts a multi-task learning approach, and innovatively uses independent branches to compensate for the three-phase current.
[0005] 2) "A method and device for temperature error compensation of an intelligent sensor based on a deep learning network", patent number CN115856342A, this patent discloses a method and device for temperature error compensation of an intelligent sensor based on a deep learning network. First, based on the deep learning network, a deep learning neural network model is constructed, and the deep learning neural network model is trained using a training data set. Then, the deep learning neural network model is optimized using a network optimization algorithm, and then the optimized deep learning neural network model is used to compensate for the temperature error of the intelligent sensor. This method successfully solves the technical problem that the accuracy of intelligent sensors is not high due to the influence of temperature. The MFNN method of the present invention is different from the above, and uses a deep learning model to solve the technical problem that the measurement accuracy of the Rogowski coil is not high due to the influence of phase-to-phase interference. Summary of the invention
[0006] In order to solve the above technical problems, the purpose of the present invention is to provide a lightweight embedded implementation of the MFNN method for Rogowski coil interphase interference compensation.
[0007] The purpose of the present invention is achieved through the following technical solutions:
[0008] The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation includes:
[0009] Step A: training the MFNN model to realize the interphase interference compensation of Rogowski coil;
[0010] Step B reduces the floating point parameters of the MFNN model to reduce the memory usage and computational complexity of the model.
[0011] Step C uses C language to reproduce the MFNN model structure and implement parameter loading, and reproduce the inference results of the MFNN model under the Pytorch framework;
[0012] Step D optimizes the C-based MFNN model reasoning through parallel computing;
[0013] Step E deploys the C language-based parallel computing MFNN model in the edge computing environment to achieve real-time compensation of Rogowski coil interphase interference.
[0014] Furthermore, in step A, the MFNN model is trained based on the Pytorch framework; a multi-branch fully connected neural network MFNN model is trained to compensate for interphase interference and improve measurement accuracy; the MFNN model processes and extracts features of the current value and phase line distance information measured by the Rogowski coil in the three-phase electricity of phase A, phase B, and phase C, and finally outputs the compensated three-phase current value;
[0015] The input of the MFNN model includes four independent variables: preliminary measurement values of the Rogowski coil under phase A, phase B and phase C currents and the relative distances between phase A, phase C and phase B.
[0016] Furthermore, the MFNN model adopts a multi-branch fully connected neural network structure, extracts features between input variables through multiple layers of neurons, and simultaneously completes interference compensation through a fully connected layer while extracting features, and then outputs the compensated three-phase current value;
[0017] The MFNN model includes two modules: a shared feature extraction module and a multi-branch current prediction module. The shared feature extraction module consists of two series-connected fully connected layers, which are used to extract complex relationships and nonlinear features between input variables; the multi-branch current prediction module consists of three branches, which predict the three-phase current values of phase A, phase B and phase C respectively according to the features output by the shared feature extraction module.
[0018] Furthermore, step B includes converting the MFNN model trained under the Pytorch framework in step A, that is, lightweighting the floating-point parameters used in the original MFNN model before conversion: that is, converting the original high-data-precision MFNN model that uses 32-bit floating-point numbers to represent weights and activation values into a lightweight model, thereby reducing the size of the model and speeding up the calculation.
[0019] Furthermore, the lightweight process includes:
[0020] 1) Determine the minimum min and maximum max of each weight or activation value;
[0021] min=min(x),max=max(x)
[0022] Among them, x is the tensor to be quantized, including weights and activation values;
[0023] 2) Calculate the scaling factor scale required for quantization:
[0024]
[0025] Where n is the target quantization bit number, for INT8, n = 8;
[0026] 3) Determine the value of the zero point during the quantization process:
[0027]
[0028] 4) Convert the floating point number to an integer using the scaling factor and zero point:
[0029]
[0030] Wherein, q is the quantized integer value;
[0031] 5) Dequantization formula: Convert the quantized integer value back to a floating point number:
[0032] x′=scale·(q-zero point)+min.
[0033] Further, the step C comprises:
[0034] 1) Reproduction of MFNN model structure definition: Define the fully connected layer and inter-layer connection relationship of the MFNN model in C language;
[0035] 2) Save the trained MFNN model parameters and load them in the C language program;
[0036] 3) Perform tensor operations and function activation in C language to achieve inference results consistent with the lightweight model.
[0037] Furthermore, in C language, the network layer is defined as a structure, and the calculation is completed layer by layer through multiple layers of loops; specifically, it includes:
[0038] Define a structure variable to describe the fully connected layer of the MFNN model. The structure contains: a variable representing the number of neurons in this layer, a variable representing the dimension of the input data in this layer, the address of the weight matrix of the neurons in this layer, the address of the bias vector of the neurons in this layer, and the address of the predicted value vector of the neurons in this layer;
[0039] Another structure variable is defined to describe the model to be implemented, wherein the structure includes: a layer structure variable representing a shared feature extraction module, and a layer structure variable representing a multi-branch current prediction module.
[0040] Furthermore, the model parameters saved in the form of .pt files in PyTorch are converted and saved in csv format through C language loading, and the weight matrix and bias vector are saved separately for the parameters of each layer, where the weight matrix is saved as a two-dimensional matrix, and each row is the input weight of a neuron; the bias vector is saved as a one-dimensional array, and each element corresponds to the bias of a neuron; it is expressed as:
[0041]
[0042] Among them, W is the weight and b is the bias. When loading, the variables in each layer of the structure are assigned specified values, and memory space is opened according to the value of the variable. Its first address is saved in the structure, and the MFNN model parameters in the csv file are sent to the opened memory space layer by layer.
[0043] Furthermore, in step D, during the reasoning process of the MFNN model, the forward propagation passes the input data layer by layer and calculates the final prediction result. During the calculation, the forward propagation operation process needs to be optimized, specifically:
[0044] In the MFNN model, the output prediction value a of each neuron can be expressed as:
[0045] a=f(w·x+b)
[0046] Among them, f is the activation function, w represents the weight vector of the neuron, x is the input feature vector, and b is the bias. To avoid repeated calculations of each neuron, the vectorization operation represents the output operation of the neuron as an overall matrix operation, thereby reducing the computational overhead. By introducing the vectorization formula, the output value of the entire layer of neurons is calculated as:
[0047] A=f(W·X+B)
[0048] Among them, A is the vector of output values of neurons in this layer, W is the weight matrix of neurons in this layer, X is the vector of input eigenvalues, and B is the vector of biases of neurons in this layer; vectorization integrates the calculation of each layer into one matrix multiplication and vector addition, thereby achieving parallelization.
[0049] Furthermore, in the step E, the MFNN model implemented in C language is deployed on the edge computing device STM32 microcontroller;
[0050] An ADC module is configured on the STM32 to realize real-time acquisition of the initial signal of the Rogowski coil, and the collected data is passed to the MFNN model for processing through the sampling rate. The MFNN model uses the operation of STM32 to infer the three-phase current collected by the Rogowski coil and the preset phase-to-phase distance, so as to compensate for the interference between the Rogowski coil lines in the edge environment.
[0051] Compared with the prior art, one or more embodiments of the present invention may have the following advantages:
[0052] By converting the floating-point parameters of the model into low-precision representation, not only the memory usage of the model is greatly reduced, but also the computational complexity is significantly reduced; the core structure of the model is simplified by using C language, especially the loading and management of model parameters are successfully realized, and the model is efficiently inferred in an environment that does not rely on the framework, while ensuring the accuracy and consistency of the model reasoning results; the reasoning process is optimized by parallel computing, combined with multi-threading or multi-core computing technology, thereby significantly improving the overall reasoning efficiency; the deep learning model of C language is deployed in an edge computing environment, where data processing is closer to the device itself and can be processed in real time at the source of signal acquisition. Compared with the traditional method of transmitting data to a remote server and then returning the results, edge deployment can effectively reduce latency and improve the real-time and security of the system. The present invention not only meets the special needs of the edge computing environment, but also realizes the lightweight and efficient model without sacrificing performance, providing a feasible solution for the application of complex deep learning models in resource-constrained environments. BRIEF DESCRIPTION OF THE DRAWINGS
[0053] Figure 1 It is a workflow diagram of the lightweight embedded implementation mechanism of the MFNN method for Rogowski coil phase interference compensation. DETAILED DESCRIPTION
[0054] In order to make the purpose, technical solutions and advantages of the present invention more clear, the present invention will be further described in detail below in conjunction with embodiments and drawings.
[0055] like Figure 1 As shown in FIG. 1 , the workflow of the lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation includes the following steps:
[0056] Step 10: Train the MFNN model to realize Rogowski coil interphase interference compensation;
[0057] Step 20: Lightweight the floating point parameters of the MFNN model to reduce the memory usage and computational complexity of the model.
[0058] Step 30: Use C language to reproduce the MFNN model structure and implement parameter loading, and reproduce the inference results of the MFNN model under the Pytorch framework;
[0059] Step 40: Optimizing the C language-based MFNN model reasoning through parallel computing;
[0060] Step 50 deploys a C-based parallel computing MFNN model in an edge computing environment to achieve real-time compensation of Rogowski coil interphase interference.
[0061] In the above step 10, when using the Rogowski coil, the interphase interference will significantly affect the measurement accuracy of the three-phase current, thereby having an adverse effect on the measurement and control system. In order to improve the measurement accuracy of the Rogowski coil, a multi-branch fully connected neural network (MFNN) model was trained to compensate for the interphase interference and improve the measurement accuracy. The MFNN model processes and extracts features of the current value and the distance between the phase lines measured by the Rogowski coil in the three-phase electricity of A, B, and C, and finally outputs the compensated three-phase current value, thereby improving the system's ability to reflect the actual current value.
[0062] The input of the model includes four independent variables: the original measurement values of the three-phase current (i.e., the preliminary measurement values of the Rogowski coil under the current of phases A, B, and C) and the relative distances of phases A and C to phase B. In particular, since phases A and C are symmetrical relative to phase B, the AB distance and the BC distance remain consistent, and a single variable can be used to represent these two distances.
[0063] The MFNN model adopts a multi-branch fully connected neural network structure, which can extract features between input variables through multi-layer neurons, and compensate for interference through the fully connected layer based on feature extraction, and finally output the compensated three-phase current value. The MFNN model consists of two modules: a shared feature extraction module and a multi-branch current prediction module. The shared feature extraction module consists of two series fully connected layers, which are used to automatically extract complex relationships and nonlinear features between input variables; the multi-branch current prediction module consists of 3 branches, which predict the three-phase current values of A, B, and C respectively according to the features output by the shared feature extraction module.
[0064] In the above step 20, the high data precision MFNN model trained based on the Pytorch framework in A is converted. The original model uses 32-bit floating point numbers (FP32) to represent weights and activation values. Lightweighting refers to converting the original high data precision MFNN model with floating point numbers representing weights and activation values into a lightweight model, where the floating point numbers are converted to lower precision data format integers (INT8), thereby reducing the size of the model and speeding up the calculation speed. The quantization process can be divided into the following steps:
[0065] ① Determine the minimum (min) and maximum (max) values for each weight or activation value.
[0066] min=min(x),max=max(x)
[0067] Where x is the tensor to be quantized, including weights and activation values.
[0068] ② Calculate the scaling factor required for quantization.
[0069]
[0070] Where n is the target quantization bit number, for INT8, n=8.
[0071] ③Determine the value of the zero point during the quantization process.
[0072]
[0073] ④ Convert the floating point number to an integer using the scaling factor and zero point.
[0074]
[0075] Where q is a quantized integer value.
[0076] ⑤ Dequantization formula: Convert the quantized integer value back to a floating point number, usually used in the model inference stage.
[0077] x′=scale·(q-zero point)+min
[0078] In step 30 above, the task of transferring the MFNN model from a high-level framework to a low-level programming environment is to optimize the performance of the MFNN model and improve the running efficiency of the model on embedded devices. Models trained based on the PyTorch framework usually contain complex tensor operations, automatic gradient solving, and graph structure definition. These frameworks use high-level data structures (such as tensors) and automated tools to manage the parameters and structure of the model. When implemented in C language, it is necessary to manually define the structure of the model, load the parameters of the model, and perform inference. This reproduction requires overcoming the challenges of the lack of automation functions in high-level frameworks, while ensuring model performance and accuracy in different environments. Specifically, the goals of this work include:
[0079] ① Reproduction of model structure definition: Define the fully connected layer and inter-layer connection relationship of the MFNN model in C language.
[0080] ② Save the trained MFNN model parameters (including weights and bias terms) and load them in the C language program.
[0081] ③Implement tensor operations, activation functions, etc. in C language to achieve inference results consistent with the original PyTorch model.
[0082] In C language, the network layer can be defined as a structure, and the calculation is completed layer by layer through multi-layer loops. Specifically: define a structure variable to describe the fully connected layer of the MFNN model. The structure contains the following contents: variables representing the number of neurons in this layer, variables representing the dimension of the input data in this layer, the weight matrix address of the neurons in this layer, the address of the bias vector of the neurons in this layer, and the address of the predicted value vector of the neurons in this layer. Define another structure variable to describe the model to be implemented. The structure contains the following contents: layer structure variables representing the shared feature extraction module and layer structure variables representing the multi-branch current prediction module.
[0083] The model parameter storage format in the PyTorch framework is in the form of tensors, while in C language, arrays are usually used to represent tensors. In order to ensure the accuracy of the inference results, the model weights and biases need to be read in through a data loading method that is consistent with the parameter format obtained by PyTorch training. In PyTorch, model parameters are saved in the form of .pt files. In order to facilitate C language loading, these parameters are saved in csv format. For the parameters of each layer, the weights and biases are saved separately: the weight matrix is saved as a two-dimensional matrix, and each row is the input weight of a neuron; the bias vector is saved as a one-dimensional array, and each element corresponds to the bias of a neuron. It can be expressed as:
[0084]
[0085] Among them, W is the weight and b is the bias. When loading, the variables in each layer of the structure are assigned specified values, and the memory space is opened according to the value of the variable. Its first address is saved in the structure, and the MFNN model parameters in the csv file are sent to the opened memory space layer by layer.
[0086] In the above step 40, in the reasoning process of the MFNN model, the forward propagation passes the input data layer by layer and calculates the final prediction result. In order to make the reasoning calculation more efficient, especially in performance-constrained environments such as embedded devices, the forward propagation operation process needs to be optimized. In the MFNN model, the output prediction value a of each neuron can be expressed as:
[0087] a=f(w·x+b)
[0088] Among them, f is the activation function, w is the weight vector of the neuron, x is the input feature vector, and b is the bias. In order to avoid repeated calculations of each neuron, the vectorization operation represents the output operation of the neuron as an overall matrix operation, thereby reducing the computational overhead. By introducing the vectorization formula, the output value of the entire layer of neurons is calculated as:
[0089] A=f(W·X+B)
[0090] Among them, A is the vector of output values of neurons in this layer, W is the weight matrix of neurons in this layer, X is the vector of input eigenvalues, and B is the vector of biases of neurons in this layer. Vectorization integrates the calculation of each layer into one matrix multiplication and vector addition, thereby achieving parallelization and avoiding the time and memory waste caused by neuron-by-neuron transmission.
[0091] Through vectorization, data only needs to perform matrix operations when it is passed between layers. This method can effectively utilize the parallel computing capabilities of the hardware and significantly reduce the clock cycles required for calculations. For embedded systems, vectorized operations can also reduce the frequency of memory accesses, making data more continuous in the cache, thereby further accelerating calculations.
[0092] In the process of model calculation, a large number of parameters often need to be passed between functions. In an embedded environment, in order to reduce the stack overhead of function calls, address passing can be used, that is, passing the address of the parameter between functions instead of directly passing the parameter value. This not only reduces the use of the stack, but also avoids a large amount of data copying when calling functions, thereby improving overall performance.
[0093] The advantages of address passing are: ① reducing the use of stack space and improving resource utilization; ② avoiding memory copying of parameter passing and shortening the transfer time; ③ using pointer passing is more efficient than array subscript addressing because pointer addressing usually takes up fewer resources in embedded systems.
[0094] By passing addresses, especially in functions that are called multiple times, the system's resource consumption can be reduced, ensuring that embedded devices can still quickly execute model reasoning under limited resources.
[0095] Static variables are also used in embedded reasoning optimization. By using the static keyword to modify variables in functions that are frequently called during reasoning, the variables are prevented from being repeatedly created and released each time they are called. This not only reduces the memory allocation overhead, but also speeds up access, making it suitable for scenarios that require high computing efficiency during reasoning.
[0096] The advantages of static variables are as follows: ①Persistence: Static variables remain valid throughout the life cycle of the program, and memory is only allocated when it is first called, avoiding resource consumption caused by repeated allocation; ②Access speed: The memory location of static variables is fixed, and the system can access them faster without having to re-search the memory address. ③Reduced resource competition: In a resource-constrained environment, excessive occupation and competition of memory resources are avoided.
[0097] Through the above optimization methods, embedded systems can achieve efficient model reasoning at a lower hardware cost. Vectorization, address transfer, and the use of static variables each have their own focus, and can be flexibly combined in specific embedded applications to ensure efficient reasoning and reasonable use of system resources. These methods can not only improve the system's computing speed, but also make the generation of reasoning results more stable and reliable, meeting real-time requirements.
[0098] In the above step 50, the MFNN model implemented in C language is deployed on the resource-constrained edge computing device (STM32 microcontroller).
[0099] The ADC (Analog-to-Digital Converter) module is configured on the STM32 to realize the real-time acquisition of the initial signal of the Rogowski coil. Through the appropriate sampling rate, the data is directly passed to the MFNN model for processing after acquisition. The MFNN model uses the computing power of the STM32 to infer the three-phase current collected by the Rogowski coil and the preset phase-to-phase distance. It can effectively compensate for the inter-line interference of the Rogowski coil in the edge environment, improve the measurement accuracy of the Rogowski coil, and achieve fast response and real-time processing capabilities.
[0100] Although the embodiments disclosed in the present invention are as above, the above contents are only embodiments adopted for facilitating the understanding of the present invention and are not intended to limit the present invention. Any technician in the technical field to which the present invention belongs can make any modifications and changes in the form and details of the implementation without departing from the spirit and scope disclosed in the present invention, but the patent protection scope of the present invention shall still be subject to the scope defined in the attached claims.
Claims
1. A lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation, characterized by: The following steps are involved: Step A: training the MFNN model to realize the interphase interference compensation of Rogowski coil; Step B reduces the floating point parameters of the MFNN model to reduce the memory usage and computational complexity of the model. Step C uses C language to reproduce the MFNN model structure and implement parameter loading, and reproduce the inference results of the MFNN model under the Pytorch framework; Step D optimizes the C-based MFNN model reasoning through parallel computing; Step E deploys the C language-based parallel computing MFNN model in the edge computing environment to achieve real-time compensation of Rogowski coil interphase interference.
2. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 1 is characterized in that: In the step A, the MFNN model is trained based on the Pytorch framework; a multi-branch fully connected neural network MFNN model is trained to compensate for interphase interference and improve measurement accuracy; the MFNN model processes and extracts features of the current value and phase line distance information measured by the Rogowski coil in the three-phase electricity of phase A, phase B, and phase C, and finally outputs the compensated three-phase current value; The input of the MFNN model includes four independent variables: preliminary measurement values of the Rogowski coil under phase A, phase B and phase C currents and the relative distances between phase A, phase C and phase B.
3. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 2 is characterized in that: The MFNN model adopts a multi-branch fully connected neural network structure, extracts features between input variables through multi-layer neurons, and completes interference compensation through the fully connected layer while extracting features, and then outputs the compensated three-phase current value; The MFNN model includes two modules: a shared feature extraction module and a multi-branch current prediction module, wherein the shared feature extraction module is composed of two series-connected fully connected layers for extracting complex relationships and nonlinear features between input variables; The multi-branch current prediction module consists of three branches, which predicts the three-phase current values of phase A, phase B and phase C respectively according to the features output by the shared feature extraction module.
4. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 1 is characterized in that: The step B includes converting the MFNN model trained under the Pytorch framework in step A, that is, lightweighting the floating-point parameters used in the original MFNN model before the conversion: that is, converting the original high-data-precision MFNN model that uses 32-bit floating-point numbers to represent weights and activation values into a lightweight model, thereby reducing the size of the model and speeding up the calculation.
5. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 4 is characterized in that: The lightweight process includes: 1) Determine the minimum min and maximum max of each weight or activation value; min=min(x),max=max(x) Among them, x is the tensor to be quantized, including weights and activation values; 2) Calculate the scaling factor scale required for quantization: Where n is the target quantization bit number, for INT8, n = 8; 3) Determine the value of the zero point during the quantization process: 4) Convert the floating point number to an integer using the scaling factor and zero point: Wherein, q is the quantized integer value; 5) Dequantization formula: Convert the quantized integer value back to a floating point number: x′=scale·(q-zero point)+min.
6. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 1 is characterized in that: The step C comprises: 1) Reproduction of MFNN model structure definition: Define the fully connected layer and inter-layer connection relationship of the MFNN model in C language; 2) Save the trained MFNN model parameters and load them in the C language program; 3) Perform tensor operations and function activation in C language to achieve inference results consistent with the lightweight model.
7. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 6 is characterized in that: In C language, the network layer is defined as a structure, and the calculation is completed layer by layer through multiple layers of loops; specifically, it includes: Define a structure variable to describe the fully connected layer of the MFNN model. The structure contains: a variable representing the number of neurons in this layer, a variable representing the dimension of the input data in this layer, the address of the weight matrix of the neurons in this layer, the address of the bias vector of the neurons in this layer, and the address of the predicted value vector of the neurons in this layer; Another structure variable is defined to describe the model to be implemented, wherein the structure includes: a layer structure variable representing a shared feature extraction module, and a layer structure variable representing a multi-branch current prediction module.
8. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 6 is characterized in that: The model parameters saved in the .pt file in PyTorch are converted to csv format by loading in C language, and the weight matrix and bias vector are saved separately for the parameters of each layer. The weight matrix is saved as a two-dimensional matrix, and each row is the input weight of a neuron; the bias vector is saved as a one-dimensional array, and each element corresponds to the bias of a neuron; it is expressed as: Among them, W is the weight and b is the bias. When loading, the variables in each layer of the structure are assigned specified values, and memory space is opened according to the value of the variable. Its first address is saved in the structure, and the MFNN model parameters in the csv file are sent to the opened memory space layer by layer.
9. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 1 is characterized in that: In step D, during the reasoning process of the MFNN model, the forward propagation passes the input data layer by layer and calculates the final prediction result. During the calculation, the forward propagation operation process needs to be optimized, specifically: In the MFNN model, the output prediction value a of each neuron can be expressed as: a=f(w·x+b) Among them, f is the activation function, w represents the weight vector of the neuron, x is the input feature vector, and b is the bias. To avoid repeated calculations of each neuron, the vectorization operation represents the output operation of the neuron as an overall matrix operation, thereby reducing the computational overhead. By introducing the vectorization formula, the output value of the entire layer of neurons is calculated as: A=f(W·X+B) Among them, A is the vector of output values of neurons in this layer, W is the weight matrix of neurons in this layer, X is the vector of input eigenvalues, and B is the vector of biases of neurons in this layer; vectorization integrates the calculation of each layer into one matrix multiplication and vector addition, thereby achieving parallelization.
10. The lightweight embedded implementation mechanism of the MFNN method for Rogowski coil interphase interference compensation according to claim 1 is characterized in that: In the step E, the MFNN model implemented in C language is deployed on the edge computing device STM32 microcontroller; An ADC module is configured on the STM32 to realize real-time acquisition of the initial signal of the Rogowski coil, and the collected data is passed to the MFNN model for processing through the sampling rate. The MFNN model uses the operation of STM32 to infer the three-phase current collected by the Rogowski coil and the preset phase-to-phase distance, so as to compensate for the interference between the Rogowski coil lines in the edge environment.
Citation Information
Patent Citations
Embedded implementation system and method of structured light three-dimensional measurement algorithm
CN107860312A
Method and device for realizing code integration of electronic product based on embedded mode
CN116540990A
Structured light measurement method and system for correcting measurement error based on deep learning
CN117036453A