Cross-platform model migration framework structure based on federated learning
Through ONNX technology and FATE framework, combined with hardware acceleration technology, the problem of cross-platform model migration and training in federated learning is solved, efficient conversion, training and aggregation of models are achieved, and training efficiency and data privacy protection are improved.
Patent Information
- Application Number
- CN202410845694.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-27
- Publication Date
- 2024-10-18
AI Technical Summary
Existing federated learning technology is difficult to implement cross-platform model migration and training. There are problems such as incompatible model formats, insufficient hardware acceleration support, and inconsistent representation of model parameters, resulting in low training efficiency and insufficient data privacy protection.
ONNX technology is used for model format conversion, and the FATE framework is used to achieve distributed data processing and model training. It is combined with hardware acceleration technologies such as TensorFlow Lite, Core ML, ONNX Runtime, and TensorRT to achieve cross-platform model conversion, training, and aggregation, and through dynamic parameters Called to ensure consistency of model parameters.
It achieves the flexibility and practicality of cross-platform models, improves training efficiency, ensures data privacy and security, and solves the problems of difficult model migration and low training efficiency.
Smart Images

Figure CN118798325A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of artificial intelligence technology, and specifically relates to a cross-platform model migration framework structure based on federated learning. Background Art
[0002] With the continuous advancement of science and technology, machine learning and artificial intelligence technologies have penetrated into various fields. Federated learning, as an emerging distributed machine learning method, is gradually gaining widespread attention. Its basic principle is to allow multiple devices or nodes to collaborate in training and jointly build a shared machine learning model under the premise of protecting data privacy. The advantages of this approach are obvious: it can not only protect the user's privacy data, but also improve the accuracy and generalization ability of the model through collective wisdom. However, current federated learning research and applications are mostly concentrated on a single platform or device, making cross-platform model migration and training difficult. The existing federated learning framework has certain limitations in model conversion, training acceleration, and cross-platform model aggregation, and it is difficult to meet the diverse needs in practical applications.
[0003] Most of the existing federated learning research and applications are concentrated on a single platform or device, making it difficult to achieve cross-platform model migration and training. The development trend of federated learning is gradually evolving towards cross-platform, high-efficiency, and easy aggregation, but the challenges it faces are becoming increasingly obvious. First, on different operating system platforms, such as Android, iOS, Windows, Linux, etc., the model formats are incompatible with each other, which makes federated learning complex in cross-platform applications. These platforms each have their own data formats and standards, making it difficult to directly apply a model trained on one platform to another. In addition to platform compatibility issues, existing federated learning frameworks also face many challenges in the model training process. Among them, the lack of hardware acceleration support is a significant problem. In the era of big data and deep learning, efficient hardware support is crucial to improving training speed. However, the current federated learning system has obvious deficiencies in this regard, resulting in low training efficiency and inability to meet the growing data processing needs. In addition, the model parameter representation methods on different platforms are not unified, which increases the difficulty of global model aggregation. The difference in model parameters requires data processing and conversion when integrating models from various platforms, which increases the difficulty and complexity of global model aggregation. Summary of the invention
[0004] 1. Technical issues to be resolved
[0005] The technical problem to be solved by the present invention is: how to provide a cross-platform model migration framework structure based on federated learning, using ONNX technology and FATE framework to realize cross-platform model conversion, training and aggregation, improve the flexibility and practicality of federated learning, and solve multiple key problems in the prior art. ONNX technology can uniformly convert models trained by different platforms and different frameworks into a standardized format, which has wide compatibility and high portability, ensuring that the model can be migrated between different systems or devices. The FATE framework provides powerful federated learning capabilities, which supports distributed data processing and model training while ensuring data security and privacy. Thus, the present invention can realize cross-platform model collaborative training without directly sharing original data, which is crucial for data privacy protection. Through this framework, the present invention can solve key problems such as difficulty in cross-platform model migration, low training efficiency and insufficient data privacy protection in the prior art.
[0006] (II) Technical solution
[0007] In order to solve the above technical problems, the present invention provides a cross-platform model migration framework structure based on federated learning, which uses ONNX technology and FATE framework to realize cross-platform federated learning model conversion, training and aggregation; including:
[0008] (1) Create a model conversion module; use ONNX technology to convert machine learning models written in Python into formats suitable for different platforms (such as Android, iOS, Windows, and Linux); ONNX (Open Neural Network Exchange) technology is an open standard for representing machine learning models. It enables machine learning developers to easily convert models written in Python into formats suitable for various platforms; through ONNX, model interoperability between different platforms has been significantly improved, thus eliminating barriers between platforms;
[0009] (2) For mobile devices, use the TensorFlow Lite (TFLite) format. TFLite is a lightweight solution optimized for mobile and embedded devices. It reduces the size of the model and the resource consumption at runtime by converting the TensorFlow model to a more efficient format while maintaining the accuracy of the model. This makes TFLite an ideal choice for deploying complex machine learning models on mobile devices with limited resources. To convert the machine learning model to the TensorFlow Lite format using ONNX technology, the original data must first be cleaned and preprocessed to ensure data quality and meet the requirements of model training. According to the requirements of the model, feature engineering such as data standardization and normalization is performed. Next, the model is exported to the ONNX format. The ONNX model is converted to a TensorFlow model using tools such as onnx-tensorflow. Then, the TensorFlow model is converted to the TensorFlow Lite format using the tflite_convert tool provided by TensorFlow. After the conversion is complete, the model is loaded and run using the interpreter provided by TensorFlow Lite, and the converted TensorFlow Lite model is verified to ensure that its performance and accuracy are comparable to the original model.
[0010] (3) For desktop and server platforms, use other suitable deep learning backends, including ONNX Runtime, TensorRT, PyTorch, and TensorFlow. ONNX Runtime is a cross-platform machine learning inference engine that supports a variety of hardware accelerators and provides efficient model execution performance. TensorRT is a deep learning inference engine developed by NVIDIA that is optimized for its GPU and can achieve extremely high inference speed on NVIDIA hardware. PyTorch and TensorFlow are both widely used deep learning frameworks that not only perform well in model training, but also provide strong support for model inference. First, call the API provided by the framework to perform model serialization, export the model trained in Python using a specific framework (such as PyTorch, TensorFlow, etc.) to the ONNX format, and generate an ONNX model file. After exporting the ONNX model, use the verification tool provided by ONNX to ensure the integrity and correctness of the model to avoid information loss or inconsistency during the model conversion process.
[0011] (4) Create a federated learning training module; use the FATE framework to implement federated learning training, FATE (Federated AI Technology Federated Learning Enabler is an open source framework for federated learning. It builds a secure and efficient federated learning environment based on multi-party secure computing (MPC) and homomorphic encryption (HE) technologies. The framework enables enterprises and institutions to collaborate on data while protecting data security and privacy. The FATE framework is used to implement federated learning training. First, each client device independently trains the model locally, calculates the gradient and updates the model. When necessary, the encrypted gradient information is exchanged to ensure data security. First, the participants use the received global model as input and use the client's local data for training. During the training process, the FATE framework ensures the security and privacy of the data. After the local model is trained, the descent gradient obtained is encrypted and uploaded to the FATE platform. After the FATE platform receives all the uploaded encrypted gradients, it aggregates the models received from the client into a new global model, obtains new descent gradients through federated averaging, and updates the global model. Finally, the new results are sent back to the client, and the client updates to a brand new model. After the training is completed, the model is evaluated to verify its performance. The FATE framework provides a variety of evaluation indicators and methods, including accuracy, recall, and F1 score.
[0012] (5) Create a training acceleration module. First, use the GPU acceleration function of TensorFlow Lite on the Android device to improve the local model training speed. TensorFlow Lite is a lightweight version of TensorFlow designed for mobile and embedded devices. It supports running machine learning models directly on the device without relying on network connections or remote servers. First, make sure that the device supports OpenCL or OpenGL ES 3.1 and above GPUs. Next, integrate the TensorFlow Lite library for Android into the Android device. Then prepare the model and convert the pre-trained TensorFlow model to the TensorFlow Lite format using the converter tool provided by TensorFlow. Next, configure GPU acceleration and load and run the model in the Android application using the TensorFlow Lite Interpreter API. When creating an Interpreter instance, configure the GPU acceleration option and then set a specific GPU delegate (GpuDelegate) that allows TensorFlow Lite to use the GPU for computing. Finally, run the model and use the Interpreter instance to run the model for training or inference operations.
[0013] (6) On iOS devices, use Core ML's NPU acceleration function to improve model training efficiency; the Core ML framework provides native support for machine learning models on iOS devices by using the Neural Engine (NPU) for hardware acceleration; first, prepare the model and convert the machine learning model to the Core ML format; Apple provides a conversion tool that supports model conversion from multiple machine learning frameworks; next, integrate the Core ML model, add the converted Core ML format file to the iOS project, and use Xcode's Core ML tool to integrate it into the application; finally, use the model and load and run the model in the iOS application through the Core ML API; when the model is running, Core ML will automatically use the device's NPU for hardware acceleration, thereby improving training efficiency;
[0014] (7) On Windows and Linux platforms, use hardware acceleration technologies such as CUDA and TensorRT to improve model training and reasoning speed; CUDA is a parallel computing platform developed by NVIDIA, and TensorRT is NVIDIA's optimized reasoning engine; First, install CUDA and TensorRT; Next, prepare the model and convert the machine learning model into a format compatible with TensorRT; Then, optimize the model and use the tools provided by TensorRT to optimize the model, including layer fusion and precision calibration operations to improve reasoning performance; Finally, load and run the model. In the application, use the TensorRT API to load the optimized model and perform training and reasoning operations; TensorRT automatically uses CUDA cores for efficient parallel computing, thereby improving training and reasoning speed;
[0015] (8) Create a cross-platform model aggregation module; during the model conversion process, record the information of each layer of model parameters; first, traverse the model layer by layer, and use the API provided by the ONNX framework to traverse the model layer by layer; ONNX provides a standardized interface that makes it easy to obtain the structure and parameter information of each layer of the model; when traversing each layer, obtain the key information of the layer, such as the name, type, input and output nodes, and weight parameters; next, identify and extract parameters. For each layer, call the functions in the `onnx.helper` module, such as `onnx.helper.printable_graph`, to extract the structural information of the model, and use the `onnx.numpy_helper` module to convert the tensors in the model into NumPy arrays, thereby extracting the parameter values of each layer; then, record the parameter information and save the extracted parameter information in a structured format, which can be exported to JS ONNX or YAML format to record the name, type, input and output shape, and weight of each layer; standard libraries in Python, such as `json` and `yaml`, can be used to record and save parameter information; then, parameter verification is performed. After extracting and recording parameter information, parameter verification is performed to ensure the integrity and correctness of the information; verification tools provided by ONNX, such as `onnx.checker.check_model`, are used to check the parameters extracted from each layer to ensure that no information is lost or inconsistent during the model conversion process; finally, parameter calls are dynamically generated. During the model training process, these parameters are called using dynamically generated methods based on the pre-saved parameter information; the training program can dynamically construct parameter call statements based on the structure of the model, and load and apply these parameters in real time; this approach not only improves the flexibility of training, but also ensures the consistency and correctness of the parameters.
[0016] (III) Beneficial effects
[0017] Compared with the prior art, the key points of the present invention are
[0018] Key point 1: Provides ONNX-based model conversion technology. It realizes the conversion of Python models to TFLite, CoreML, ONNX and other formats, ensuring the consistency of model training and inference methods on different platforms.
[0019] Key point 2: It provides federated learning training adapted to the FATE framework. It realizes cross-platform local model training and global model aggregation. Through the FATE framework, it ensures the effective transmission and aggregation of model parameters.
[0020] Key point 3: It provides hardware acceleration technology. GPU and NPU are used to improve the model training speed, solving the problem of low efficiency of cross-platform model training.
[0021] Key point 4: It provides a cross-platform model aggregation method. It unifies the model parameter representation of different platforms to ensure the correctness and consistency of model aggregation. It calls these parameters through dynamically generated methods to achieve cross-platform model aggregation.
[0022] Effects of the Invention
[0023] The present invention provides a cross-platform model migration framework structure based on federated learning, which uses ONNX technology and FATE framework to realize cross-platform conversion, training and aggregation of models, solves multiple key problems in the prior art, and improves the flexibility and practicality of federated learning. The working principle of the present invention is to first use ONNX technology to convert models trained by different machine learning frameworks into a universal ONNX format, so that the model can be migrated between different machine learning frameworks. Then, with the help of the FATE framework, the converted model can be securely shared and learned between distributed data sources without leaking the original data, thereby ensuring data privacy and security. ONNX technology and FATE framework play a core role in the present invention. ONNX technology provides a bridge for model conversion, so that the model can maintain consistent performance and accuracy in different deep learning environments. The FATE framework provides a secure computing environment, allowing multiple participants to jointly train models without sharing original data, which promotes the implementation of federated learning. BRIEF DESCRIPTION OF THE DRAWINGS
[0024] Figure 1 The overall execution flow chart of the cross-platform model migration framework based on federated learning.
[0025] Figure 2 The following is a flowchart of model conversion and aggregation based on ONNX and FATE framework. DETAILED DESCRIPTION
[0026] In order to make the purpose, content, and advantages of the present invention more clear, the specific implementation methods of the present invention are further described in detail below in conjunction with the accompanying drawings and examples.
[0027] In order to solve the above technical problems, the present invention provides a cross-platform model migration framework structure based on federated learning, which uses ONNX technology and FATE framework to realize cross-platform federated learning model conversion, training and aggregation; including:
[0028] (1) Create a model conversion module; use ONNX technology to convert machine learning models written in Python into formats suitable for different platforms (such as Android, iOS, Windows, and Linux); ONNX (Open Neural Network Exchange) technology is an open standard for representing machine learning models. It enables machine learning developers to easily convert models written in Python into formats suitable for various platforms; through ONNX, model interoperability between different platforms has been significantly improved, thus eliminating barriers between platforms;
[0029] (2) For mobile devices, use the TensorFlow Lite (TFLite) format. TFLite is a lightweight solution optimized for mobile and embedded devices. It reduces the size of the model and the resource consumption at runtime by converting the TensorFlow model to a more efficient format while maintaining the accuracy of the model. This makes TFLite an ideal choice for deploying complex machine learning models on mobile devices with limited resources. To convert the machine learning model to the TensorFlow Lite format using ONNX technology, the original data must first be cleaned and preprocessed to ensure data quality and meet the requirements of model training. According to the requirements of the model, feature engineering such as data standardization and normalization is performed. Next, the model is exported to the ONNX format. The ONNX model is converted to a TensorFlow model using tools such as onnx-tensorflow. Then, the TensorFlow model is converted to the TensorFlow Lite format using the tflite_convert tool provided by TensorFlow. After the conversion is complete, the model is loaded and run using the interpreter provided by TensorFlow Lite, and the converted TensorFlow Lite model is verified to ensure that its performance and accuracy are comparable to the original model.
[0030] (3) For desktop and server platforms, use other suitable deep learning backends, including ONNX Runtime, TensorRT, PyTorch, and TensorFlow. ONNX Runtime is a cross-platform machine learning inference engine that supports a variety of hardware accelerators and provides efficient model execution performance. TensorRT is a deep learning inference engine developed by NVIDIA that is optimized for its GPU and can achieve extremely high inference speed on NVIDIA hardware. PyTorch and TensorFlow are both widely used deep learning frameworks that not only perform well in model training, but also provide strong support for model inference. First, call the API provided by the framework to perform model serialization, export the model trained in Python using a specific framework (such as PyTorch, TensorFlow, etc.) to the ONNX format, and generate an ONNX model file. After exporting the ONNX model, use the verification tool provided by ONNX to ensure the integrity and correctness of the model to avoid information loss or inconsistency during the model conversion process.
[0031] (4) Create a federated learning training module; use the FATE framework to implement federated learning training, FATE (Federated AI Technology Federated Learning Enabler is an open source framework for federated learning. It builds a secure and efficient federated learning environment based on multi-party secure computing (MPC) and homomorphic encryption (HE) technologies. The framework enables enterprises and institutions to collaborate on data while protecting data security and privacy. The FATE framework is used to implement federated learning training. First, each client device independently trains the model locally, calculates the gradient and updates the model. When necessary, the encrypted gradient information is exchanged to ensure data security. First, the participants use the received global model as input and use the client's local data for training. During the training process, the FATE framework ensures the security and privacy of the data. After the local model is trained, the descent gradient obtained is encrypted and uploaded to the FATE platform. After the FATE platform receives all the uploaded encrypted gradients, it aggregates the models received from the client into a new global model, obtains new descent gradients through federated averaging, and updates the global model. Finally, the new results are sent back to the client, and the client updates to a brand new model. After the training is completed, the model is evaluated to verify its performance. The FATE framework provides a variety of evaluation indicators and methods, including accuracy, recall, and F1 score.
[0032] (5) Create a training acceleration module. First, use the GPU acceleration function of TensorFlow Lite on the Android device to improve the local model training speed. TensorFlow Lite is a lightweight version of TensorFlow designed for mobile and embedded devices. It supports running machine learning models directly on the device without relying on network connections or remote servers. First, make sure that the device supports OpenCL or OpenGL ES 3.1 and above GPUs. Next, integrate the TensorFlow Lite library for Android into the Android device. Then prepare the model and convert the pre-trained TensorFlow model to the TensorFlow Lite format using the converter tool provided by TensorFlow. Next, configure GPU acceleration and load and run the model in the Android application using the TensorFlow Lite Interpreter API. When creating an Interpreter instance, configure the GPU acceleration option and then set a specific GPU delegate (GpuDelegate) that allows TensorFlow Lite to use the GPU for computing. Finally, run the model and use the Interpreter instance to run the model for training or inference operations.
[0033] (6) On iOS devices, use Core ML's NPU acceleration function to improve model training efficiency; the Core ML framework provides native support for machine learning models on iOS devices by using the Neural Engine (NPU) for hardware acceleration; first, prepare the model and convert the machine learning model to the Core ML format; Apple provides a conversion tool that supports model conversion from multiple machine learning frameworks; next, integrate the Core ML model, add the converted Core ML format file to the iOS project, and use Xcode's Core ML tool to integrate it into the application; finally, use the model and load and run the model in the iOS application through the Core ML API; when the model is running, Core ML will automatically use the device's NPU for hardware acceleration, thereby improving training efficiency;
[0034] (7) On Windows and Linux platforms, use hardware acceleration technologies such as CUDA and TensorRT to improve model training and reasoning speed; CUDA is a parallel computing platform developed by NVIDIA, and TensorRT is NVIDIA's optimized reasoning engine; First, install CUDA and TensorRT; Next, prepare the model and convert the machine learning model into a format compatible with TensorRT; Then, optimize the model and use the tools provided by TensorRT to optimize the model, including layer fusion and precision calibration operations to improve reasoning performance; Finally, load and run the model. In the application, use the TensorRT API to load the optimized model and perform training and reasoning operations; TensorRT automatically uses CUDA cores for efficient parallel computing, thereby improving training and reasoning speed;
[0035] (8) Create a cross-platform model aggregation module; during the model conversion process, record the information of each layer of model parameters; first, traverse the model layer by layer, and use the API provided by the ONNX framework to traverse the model layer by layer; ONNX provides a standardized interface that makes it easy to obtain the structure and parameter information of each layer of the model; when traversing each layer, obtain the key information of the layer, such as the name, type, input and output nodes, and weight parameters; next, identify and extract parameters. For each layer, call the functions in the `onnx.helper` module, such as `onnx.helper.printable_graph`, to extract the structural information of the model, and use the `onnx.numpy_helper` module to convert the tensors in the model into NumPy arrays, thereby extracting the parameter values of each layer; then, record the parameter information and save the extracted parameter information in a structured format, which can be exported to JS ONNX or YAML format to record the name, type, input and output shape, and weight of each layer; standard libraries in Python, such as `json` and `yaml`, can be used to record and save parameter information; then, parameter verification is performed. After extracting and recording parameter information, parameter verification is performed to ensure the integrity and correctness of the information; verification tools provided by ONNX, such as `onnx.checker.check_model`, are used to check the parameters extracted from each layer to ensure that no information is lost or inconsistent during the model conversion process; finally, parameter calls are dynamically generated. During the model training process, these parameters are called using dynamically generated methods based on the pre-saved parameter information; the training program can dynamically construct parameter call statements based on the structure of the model, and load and apply these parameters in real time; this approach not only improves the flexibility of training, but also ensures the consistency and correctness of the parameters.
[0036] Example 1
[0037] This embodiment specifically includes the following steps:
[0038] Step 1: Data preparation module - data collection and cleaning. Collect the required raw data from multiple data sources, which may include structured data, semi-structured data, or unstructured data. Common data sources include databases, CSV files, API interfaces, and sensor data. The collected data usually contains noise, missing values, or erroneous data, so data cleaning is required. The steps of data cleaning include removing noise, handling missing values, and correcting data errors. For example, invalid records can be deleted, duplicate data can be removed, and outliers can be filtered. Missing values can be handled by filling the mean, nearest neighbor filling, or deleting records with missing values. Correcting data errors includes correcting incorrect values, unifying data formats (such as date formats), and correcting incorrect classification labels.
[0039] Step 2: Data preparation module - data standardization and normalization. After data cleaning is completed, the data needs to be standardized and normalized. Standardization refers to adjusting the data to the same scale. Common standardization methods include Z-Score standardization, which adjusts the data to a distribution with a mean of 0 and a standard deviation of 1. Normalization is to scale the data to a fixed range, such as scaling the data to between [0,1]. Common methods include Min-Max normalization.
[0040] Step 3: Data preparation module - data segmentation. According to the needs of model training, the data set is divided into training set, validation set and test set. The training set is used for model training, the validation set is used for parameter adjustment and selection of the best model, and the test set is used to evaluate the generalization performance of the model. When segmenting the data, it is necessary to ensure that the distribution of the data in each subset is consistent to avoid data bias. Random segmentation or segmentation based on specific rules can be used.
[0041] Step 4: Data preparation module - feature engineering. After data segmentation, feature engineering is required. Feature engineering is a key step to improve model performance. It generates meaningful features by extracting and transforming the original data. Feature extraction can extract time features from time series data and word frequency features from text data. Feature conversion can convert continuous variables into categorical variables through discretization and perform feature dimension reduction through principal component analysis (PCA). Feature selection selects features that are highly correlated with the target variable and eliminates redundant and irrelevant features through methods such as correlation analysis and feature importance analysis.
[0042] Step 5: Data preparation module - data enhancement. In order to increase the diversity of data and prevent the model from overfitting, the training data can be enhanced. Image data enhancement methods include image rotation, translation, scaling, flipping and color adjustment. Text data enhancement methods include synonym replacement, random word deletion and noise addition. Time series data enhancement methods include time point translation, random noise addition and time series segmentation.
[0043] Step 6: Data preparation module - data format conversion. After feature engineering and data enhancement are completed, the data needs to be converted according to the requirements of the target model and platform. Different platforms and frameworks have different requirements for data formats. For example, in TensorFlow, data usually needs to be converted to TFRecord format, while in PyTorch, a custom data loader can be used. When converting data formats, it is necessary to ensure that the data format matches the model input, such as adjusting the size and number of channels of the image, and ensuring that the input tensor shape is consistent with the model requirements.
[0044] Step 7: Data preparation module - data verification. Verify the prepared data to ensure the integrity and correctness of the data. Visual tools (such as Matplotlib and Seaborn) can be used to visually check the data to ensure that the data distribution is reasonable and the eigenvalues are normal. Statistical methods can also be used to check the mean, variance and other statistical quantities of the data to ensure that there are no outliers and deviations in the data.
[0045] Step 8: Model conversion module - model export. Export the machine learning model trained in Python (such as using frameworks such as TensorFlow, PyTorch, etc.) to ONNX format. Use the API provided by the framework (such as tf2onnx for TensorFlow or torch.onnx for PyTorch) to serialize and export the model. During the export process, ensure the integrity of the model structure and parameters to avoid information loss during the conversion process.
[0046] Step 9: Model conversion module - model conversion. Use ONNX model conversion tools (such as onnx-tf, onnx-coreml) to convert ONNX format models to formats suitable for different platforms. For mobile terminals, convert to TensorFlowLite (TFLite) format, using the tflite_convert tool provided by TensorFlow for conversion; for iOS devices, convert to Core ML format, using the coremltools provided by Apple for model conversion; for desktop and server platforms, convert to formats suitable for ONNX Runtime, TensorRT, etc., using ONNX related tools for conversion.
[0047] Step 10: Model conversion module - model verification. Use the verification tools of the corresponding platform (such as Interpreter of TensorFlowLite, Core ML API of Core ML) to verify the converted model to ensure that the model performance and accuracy are consistent with the original model and can run normally on the target platform.
[0048] Step 11: Federated learning training module - local model training. Each participant trains the model independently locally. Each client device performs model training locally, calculates gradients and updates the model. The FATE framework is used to ensure the security and privacy of data during training, and multi-party secure computing (MPC) and homomorphic encryption (HE) technologies are used to encrypt gradient information.
[0049] Step 12: Federated learning training module - Gradient encryption upload. After the local model training is completed, the calculated gradient is encrypted and uploaded to the FATE platform. The encryption method can use the encryption algorithm provided by the FATE framework.
[0050] Step 13: Federated Learning Training Module - Global Model Aggregation. The FATE platform receives all uploaded encrypted gradients and aggregates local gradients into a new global model using the Federated Averaging algorithm. During the aggregation process, the data privacy of each participant is protected to avoid leakage of original data.
[0051] Step 14: Federated learning training module - update the global model. The aggregated new global model is sent to each client device, and the client updates according to the new model and restarts the next round of training.
[0052] Step 15: Federated Learning Training Module - Model Performance Evaluation. Use the evaluation tools provided by the FATE framework (such as accuracy, recall, F1 score, etc.) to evaluate the performance of the trained model to ensure that the model achieves the expected accuracy and effect globally.
[0053] Step 16: Training acceleration module - mobile GPU acceleration. On the mobile side, first use the GPU acceleration function of TensorFlowLite to improve the model training speed. On Android devices, configure a GPU with OpenCL or OpenGL ES 3.1 or above, load and run the model through the Interpreter API of TensorFlow Lite, set the GPU acceleration option, and perform calculation acceleration through GpuDelegate. On iOS devices, use the NPU acceleration function of Core ML to convert the model to Core ML format, integrate it into the iOS application, load the model through the Core ML API, and use the Neural Engine (NPU) for hardware acceleration.
[0054] Step 17: Training Acceleration Module - Desktop and Server Platform Acceleration. On Windows and Linux platforms, use NVIDIA's CUDA and TensorRT technologies to accelerate the model. First, install CUDA and TensorRT, and then use the TensorRT tool to optimize the model, including layer fusion and precision calibration, to ensure that the model runs efficiently on the GPU. Next, use the TensorRT API to load the optimized model, perform training and inference operations in the application, and use CUDA cores for efficient parallel computing to increase training and inference speed.
[0055] Step 18: Cross-platform model aggregation module - model parameter extraction. During the model conversion process, the model is traversed layer by layer, and the API provided by the ONNX framework is used to extract the structure and related parameter information of each layer, and the parameter information is recorded to provide basic data support for subsequent model aggregation.
[0056] Step 19: Cross-platform model aggregation module - unified parameter format. In order to ensure that model parameters between different platforms can be correctly aggregated, a unified parameter representation method is adopted. All parameters are represented using standard formats and naming conventions, which makes it easier for the system to identify and match parameters when performing cross-platform aggregation.
[0057] Step 20: Cross-platform model aggregation module - dynamic parameter call. During the model training process, the pre-saved parameter information is used to dynamically generate parameter call statements, load and apply these parameters in real time. This method improves the flexibility of model training and ensures parameter consistency.
[0058] Step 21: Cross-platform model aggregation module - model parameter aggregation. Aggregate model parameters from different platforms according to a unified parameter format. The system automatically identifies and integrates these parameters, updates the global model, and ensures the correctness and consistency of cross-platform model aggregation.
[0059] The above is only a preferred embodiment of the present invention. It should be pointed out that for ordinary technicians in this technical field, several improvements and modifications can be made without departing from the technical principles of the present invention. These improvements and modifications should also be regarded as the scope of protection of the present invention.
Claims
1. A cross-platform model migration framework based on federated learning, characterized in that: The structure uses ONNX technology and FATE framework to achieve cross-platform federated learning model conversion, training and aggregation; including: (1) Create a model conversion module; use ONNX technology to convert machine learning models written in Python into formats suitable for different platforms; ONNX technology is an open standard for representing machine learning models, which enables machine learning developers to easily convert models written in Python into formats suitable for various platforms; through ONNX, model interoperability between different platforms has been significantly improved, thus eliminating barriers between platforms; (2) For mobile devices, use the TensorFlow Lite format. TFLite is a lightweight solution optimized for mobile and embedded devices. It reduces the size of the model and the resource consumption at runtime by converting the TensorFlow model to a more efficient format while maintaining the accuracy of the model. This makes TFLite an ideal choice for deploying complex machine learning models on mobile devices with limited resources. To convert the machine learning model to the TensorFlow Lite format using ONNX technology, the original data must first be cleaned and preprocessed to ensure data quality and meet the requirements of model training. Data standardization and normalization feature engineering are performed according to the requirements of the model. Next, the model is exported to the ONNX format. The ONNX model is converted to a TensorFlow model using onnx-tensorflow. Then, the TensorFlow model is converted to the TensorFlow Lite format using the tflite_convert tool provided by TensorFlow. After the conversion is complete, the model is loaded and run using the interpreter provided by TensorFlow Lite, and the converted TensorFlow Lite model is verified to ensure that its performance and accuracy are comparable to the original model. (3) For desktop and server platforms, use other suitable deep learning backends, including ONNX Runtime, TensorRT, PyTorch, and TensorFlow; ONNX Runtime is a cross-platform machine learning inference engine that supports a variety of hardware accelerators and provides efficient model execution performance; TensorRT is a deep learning inference engine developed by NVIDIA that is optimized for its GPU and can achieve extremely high inference speed on NVIDIA hardware; PyTorch and TensorFlow are both widely used deep learning frameworks that not only perform well in model training, but also provide strong support for model inference; First, call the API provided by the framework to perform model serialization, export the model trained in Python using a specific framework to the ONNX format, and generate an ONNX model file; After exporting the ONNX model, use the verification tools provided by ONNX to ensure the integrity and correctness of the model to avoid loss of information or inconsistency during the model conversion process; (4) Create a federated learning training module; Use the FATE framework to implement federated learning training. FATE is an open source framework for federated learning. It builds a secure and efficient federated learning environment based on multi-party secure computing and homomorphic encryption technology. The framework enables enterprises and institutions to collaborate on data while protecting data security and privacy. Use the FATE framework to implement federated learning training. First, each client device independently trains the model locally, calculates the gradient and updates the model. When necessary, the encrypted gradient information is exchanged to ensure data security. First, the participants use the received global model as input and use the client's local data for training. During the training process, the FATE framework ensures data security and privacy. After the local model training is completed, the obtained descent gradients are encrypted and uploaded to the FATE platform. After receiving all the uploaded encrypted gradients, the FATE platform aggregates the models received from the client into a new global model, obtains new descent gradients through federated averaging, and updates the global model. Finally, the new results are sent back to the client, and the client updates to a brand new model. After training, the model is evaluated to verify its performance; the FATE framework provides a variety of evaluation indicators and methods, including accuracy, recall, and F1 score; (5) Create a training acceleration module; First, on the Android device, use the GPU acceleration function of TensorFlow Lite to improve the local model training speed; TensorFlow Lite is a lightweight version of TensorFlow, designed for mobile and embedded devices. It supports running machine learning models directly on the device without relying on network connections or remote servers; First, make sure that the device supports OpenCL or OpenGL ES 3.1 and above GPUs; Next, integrate the TensorFlow Lite library for Android into the Android device; Then prepare the model and convert the pre-trained TensorFlow model to the TensorFlow Lite format using the converter tool provided by TensorFlow; Then configure GPU acceleration and load and run the model in the Android application through the TensorFlow Lite Interpreter API; When creating the Interpreter instance, configure the GPU acceleration option and then set a specific GPU delegate, which allows TensorFlow Lite to use the GPU for calculations; Finally, run the model and use the Interpreter instance to run the model for training or inference operations; (6) On iOS devices, use Core ML's NPU acceleration function to improve model training efficiency; the Core ML framework provides native support for machine learning models on iOS devices, using NeuralEngine for hardware acceleration; first, prepare the model and convert the machine learning model to Core ML format; Apple provides conversion tools that support model conversion from multiple machine learning frameworks; next, integrate the Core ML model, add the converted Core ML format file to the iOS project, and use Xcode's Core ML tool to integrate it into the application; finally, use the model and load and run the model in the iOS application through the Core ML API; when the model is running, Core ML will automatically use the device's NPU for hardware acceleration, thereby improving training efficiency; (7) On Windows and Linux platforms, use CUDA and TensorRT hardware acceleration technologies to improve model training and reasoning speed; CUDA is a parallel computing platform developed by NVIDIA, and TensorRT is NVIDIA's optimized reasoning engine; First, install CUDA and TensorRT; Next, prepare the model and convert the machine learning model into a format compatible with TensorRT; Then, optimize the model and use the tools provided by TensorRT to optimize the model, including layer fusion and precision calibration operations to improve reasoning performance; Finally, load and run the model. In the application, use the TensorRT API to load the optimized model and perform training and reasoning operations; TensorRT automatically uses CUDA cores for efficient parallel computing, thereby improving training and reasoning speed; (8) Create a cross-platform model aggregation module; during the model conversion process, record the information of each layer of model parameters; first, traverse the model layer by layer, and use the API provided by the ONNX framework to traverse the model layer by layer; ONNX provides a standardized interface that makes it easy to obtain the structure and parameter information of each layer of the model; when traversing each layer, obtain the name, type, input and output nodes, and key information of weight parameters of the layer; next, identify and extract parameters. For each layer, call the functions in the `onnx.helper` module, including `onnx.helper.printable_graph`, to extract the structural information of the model, and use the `onnx.numpy_helper` module to convert the tensors in the model into NumPy arrays, thereby extracting the parameter values of each layer; then, record the parameter information and save the extracted parameter information in a structured format, which can be used in JS The name, type, input and output shape, and weight information of each layer are recorded in ONNX or YAML format; the standard libraries in Python, including `json` and `yaml`, can be used to record and save parameter information; then, parameter verification is performed. After extracting and recording the parameter information, parameter verification is performed to ensure the integrity and correctness of the information; the verification tools provided by ONNX, including `onnx.checker.check_model`, are used to check the parameters extracted from each layer to ensure that no information is lost or inconsistent during the model conversion process; finally, parameter calls are dynamically generated. During the model training process, these parameters are called using dynamically generated methods based on the pre-saved parameter information; the training program can dynamically construct parameter call statements based on the structure of the model, and load and apply these parameters in real time; this method not only improves the flexibility of training, but also ensures the consistency and correctness of the parameters.
2. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: The ONNX (Open Neural Network Exchange) technology is an open standard for representing machine learning models. It enables machine learning developers to easily convert models written in Python into formats suitable for various platforms. Through ONNX, model interoperability between different platforms has been significantly improved, thereby eliminating barriers between platforms.
3. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: TFLite is a lightweight solution optimized for mobile and embedded devices. It reduces the size of the model and the resource consumption at runtime by converting the TensorFlow model into a more efficient format while maintaining the accuracy of the model. This makes TFLite an ideal choice for deploying complex machine learning models on mobile devices with limited resources.
4. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: ONNX Runtime is a cross-platform machine learning inference engine that supports a variety of hardware accelerators and provides efficient model execution performance. TensorRT is a deep learning inference engine developed by NVIDIA that is optimized for its GPUs and can achieve extremely high inference speeds on NVIDIA hardware. PyTorch and TensorFlow are both widely used deep learning frameworks that not only perform well in model training, but also provide strong support for model reasoning.
5. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: FATE (Federated AI Technology Enabler) is an open source framework for federated learning. It builds a secure and efficient federated learning environment based on multi-party secure computing (MPC) and homomorphic encryption (HE) technologies. The framework enables enterprises and institutions to collaborate on data while protecting data security and privacy.
6. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: TensorFlow Lite is a lightweight version of TensorFlow designed for mobile and embedded devices. It supports running machine learning models directly on the device without relying on a network connection or a remote server.
7. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: The CoreML framework provides native support for machine learning models on iOS devices by leveraging the Neural Engine (NPU) for hardware acceleration.
8. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: CUDA is a parallel computing platform developed by NVIDIA, while TensorRT is NVIDIA's optimized inference engine.
9. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: ONNX provides a standardized interface that makes it easy to obtain the structure and parameter information of each layer of the model.
10. The cross-platform model migration framework structure based on federated learning as claimed in claim 1, characterized in that: The structure belongs to the field of artificial intelligence technology.
Citation Information
Patent Citations
Federation learning method and device, equipment and storage medium
CN112580821A
Cross-platform multi-modal public opinion analysis method based on federal learning and edge calculation
CN113642700A
Federal transfer learning algorithm based on microcontroller and micro machine learning
CN116451810A
Federal learning framework, method and system combining model splitting and client matching
CN117972424A
Communication-efficient federated learning system with data protection and data security
DE202023107184U1
Cited By
NPU model optimization method and device based on TensorFlow and storage medium
CN120145888A
Cross-hardware platform AI algorithm model automatic matching migration method and system using low code development
CN120371384A
A method and system for automatic matching and migration of AI algorithm models across hardware platforms using low-code development
CN120371384B
Large language model rapid reasoning method and system based on Android system deployment
CN120821515A
