Created
January 18, 2022 17:24
-
-
Save ThiagoLira/b2bdb56182a9f790c78d5a7897d6e250 to your computer and use it in GitHub Desktop.
update function
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int Update(double[] currentState) | |
{ | |
Tensor<double> input = new DenseTensor<double>(new[] {3}); | |
input[0] = currentState[0]; | |
input[1] = currentState[1]; | |
input[2] = currentState[2]; | |
// Setup inputs and outputs | |
var inputs = new List<NamedOnnxValue>() | |
{ | |
// the model has only one input, the state tuple | |
NamedOnnxValue.CreateFromTensor<double>("0", input) | |
}; | |
using (var results = session.Run(inputs)) | |
{ | |
Tensor<double> outputs = results.First().AsTensor<double>(); | |
var maxValue = outputs.Max(); | |
var maxIndex = outputs.ToList().IndexOf(maxValue); | |
return maxIndex; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment