如何在 Microsoft.ML.onnxruntime 的 C# 编码中访问 DisposableList?

问题描述

我可以知道如何在控制台中显示黄色圆圈中的值。 我试过了

using (var results = Session.Run(outputs))
            {
                var highestIndex = results.First().AsTensor<long>().First();
                Console.WriteLine(highestIndex);

                var values = results.Last().Value;
                Console.WriteLine(values);
            }

我在highestIndex中提取的结果的[0]值, 我需要提取值的 [1.] 值,它在 First() 中,再次在 First() 和 Last() 值中以黄色圈出。 我只想在控制台中显示

1
1.7285347E-05
0.9999827

enter image description here

在堆栈溢出中尝试过,没有人能帮上忙。 我是 python 开发者,所以不确定 c# 编码。

提前致谢

解决方法

我找到了方法

            using (var results = Session.Run(outputs))
            {
                var highestIndex = results.First().AsTensor<long>().First();
                Console.WriteLine(highestIndex);
                var seq = results.Last().AsEnumerable<NamedOnnxValue>();
                var map = seq.First().AsDictionary<Int64,float>();
                var values = map.First().Value;
                Console.WriteLine("Index {0} with Probability {1}",map.First().Key,map.First().Value);
                Console.WriteLine("Index {0} with Probability {1}",map.Last().Key,map.Last().Value);
            } 

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...