在 SQL Edge 中将机器学习和 AI 与 ONNX 结合使用Machine learning and AI with ONNX in SQL Edge

Azure SQL Edge 中的机器学习支持 Open Neural Network Exchange (ONNX) 格式的模型。Machine learning in Azure SQL Edge supports models in the Open Neural Network Exchange (ONNX) format. ONNX 是一种开放的格式,可用于在不同的机器学习框架和工具之间交换模型。ONNX is an open format you can use to interchange models between various machine learning frameworks and tools.

概述Overview

若要在 Azure SQL Edge 中推理机器学习模型,首先需要获取模型。To infer machine learning models in Azure SQL Edge, you will first need to get a model. 这可以是预训练模型,也可以是使用所选框架训练的自定义模型。This can be a pre-trained model or a custom model trained with your framework of choice. Azure SQL Edge 支持 ONNX 格式,你需要将模型转换为此格式。Azure SQL Edge supports the ONNX format and you will need to convert the model to this format. 这应该不会影响模型准确度,在获取 ONNX 模型后,就可以在 Azure SQL Edge 中部署模型,然后利用使用 PREDICT T-SQL 函数的本机评分There should be no impact on model accuracy, and once you have the ONNX model, you can deploy the model in Azure SQL Edge and use native scoring with the PREDICT T-SQL function.

获取 ONNX 模型Get ONNX models

获取 ONNX 格式模型的途径:To obtain a model in the ONNX format:

限制Limitations

目前,并非所有的 ONNX 模型都受到 Azure SQL Edge 的支持。Currently, not all ONNX models are supported by Azure SQL Edge. 此支持仅限于具有以下数值数据类型的模型:The support is limited to models with numeric data types:

通过使用 CAST 和 CONVERT,可以将其他数值类型转换为支持的类型。Other numeric types can be converted to supported types by using CAST and CONVERT.

应对模型输入进行结构化处理,以便模型的每个输入都对应于表中的一列。The model inputs should be structured so that each input to the model corresponds to a single column in a table. 例如,如果使用 pandas 数据帧来训练模型,那么每个输入都应该是模型中的单独一列。For example, if you are using a pandas dataframe to train a model, then each input should be a separate column to the model.

后续步骤Next steps