问题描述
我可以知道如何在控制台中显示黄色圆圈中的值。 我试过了
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
在堆栈溢出中尝试过,没有人能帮上忙。 我是 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);
}