2

I've saved an ONNX-converted pretrained RFC model and I'm trying to use it in my API. I am able to call the saved model and make my prediction however I can't get my predicted value. The response is very complicated and I can't seem to figure it out. Here's the predicted value shape in debug mode: enter image description here

and here it is in python, I'm trying to get the second value:

enter image description here

This is what I've tried so far but I only get string values.

        var result = _inferencesession.Run(new List<NamedOnnxValue>
        {
            NamedOnnxValue.CreateFromTensor("input", attritionData.AsTensor())
        });
        var scoreValue = result.LastOrDefault().Value;
        var score = scoreValue.GetType()?.GetProperty("Value")?.Attributes;
confusedstudent
  • 353
  • 3
  • 11

1 Answers1

2

I found it ! I had to use AsEnumerable and then access the values I wanted:

       var seq = result.LastOrDefault().AsEnumerable<NamedOnnxValue>();
        var map = seq.First().AsDictionary<Int64, float>();
        var values = map.First().Value; //this is what I want
confusedstudent
  • 353
  • 3
  • 11