从节点读取数据

从节点读取数据

java net.tinyos.tools.Listen -comm serial@/dev/ttyUSB1:iris  (ttyUSB0为烧录端口,ttyUSB1才为读写端口)

java TestSerial -comal@/dev/ttyUSB1:iris
要在C#中读取ONNX节点数据,可以使用Microsoft.ML.OnnxRuntime库。以下是一个简单的示例代码,演示如何使用该库: ```csharp using System; using System.Collections.Generic; using System.Linq; using Microsoft.ML.OnnxRuntime; using Microsoft.ML.OnnxRuntime.Tensors; namespace ONNXNodeReader { class Program { static void Main(string[] args) { // Load the ONNX model var session = new InferenceSession("model.onnx"); // Get the input and output node names var inputName = session.InputMetadata.Keys.First(); var outputName = session.OutputMetadata.Keys.First(); // Create input tensor var input = new DenseTensor<float>(new[] {1, 3, 224, 224}); // Fill input tensor with data FillTensorWithRandomData(input); // Run the model and get the output var inputs = new List<NamedOnnxValue> {NamedOnnxValue.CreateFromTensor(inputName, input)}; var output = session.Run(inputs).First().AsTensor<float>(); // Print the output Console.WriteLine($"Output shape: {string.Join(",", output.Shape)}"); Console.WriteLine($"Output data: {string.Join(",", output.ToArray())}"); } static void FillTensorWithRandomData<T>(DenseTensor<T> tensor) { var random = new Random(); for (int i = 0; i < tensor.Length; i++) { tensor[i] = (T)Convert.ChangeType(random.NextDouble(), typeof(T)); } } } } ``` 在这个示例中,我们首先加载ONNX模型,然后获取输入和输出节点的名称。接下来,我们创建一个输入张量并将其填充到随机数据。最后,我们运行模型并打印输出。注意,这个示例只是一个简单的演示,实际上你可能需要根据你的具体场景进行修改。 希望这个示例可以帮助你开始在C#中读取ONNX节点数据
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值