Beispiel #1
0
        public async Task <taxiFarePredOutput> EvaluateAsync(taxiFarePredInput input)
        {
            binding.Bind("PassengerCount", input.PassengerCount);
            binding.Bind("TripTime", input.TripTime);
            binding.Bind("TripDistance", input.TripDistance);
            binding.Bind("FareAmount", input.FareAmount);
            var result = await session.EvaluateAsync(binding, "0");

            var output = new taxiFarePredOutput();

            output.PassengerCount0 = result.Outputs["PassengerCount0"] as TensorFloat;
            output.TripTime0       = result.Outputs["TripTime0"] as TensorFloat;
            output.TripDistance0   = result.Outputs["TripDistance0"] as TensorFloat;
            output.FareAmount0     = result.Outputs["FareAmount0"] as TensorFloat;
            output.Features0       = result.Outputs["Features0"] as TensorFloat;
            output.Score0          = result.Outputs["Score0"] as TensorFloat;
            return(output);
        }
Beispiel #2
0
        private async void Button_Click(object sender, RoutedEventArgs e)
        {
            var shape      = new long[] { 1, 1 };
            var modelInput = new taxiFarePredInput()
            {
                PassengerCount = TensorFloat.CreateFromArray(shape, new float[] { 1f }),
                TripTime       = TensorFloat.CreateFromArray(shape, new float[] { 1140f }),
                TripDistance   = TensorFloat.CreateFromArray(shape, new float[] { 3.75f }),
                FareAmount     = TensorFloat.CreateFromArray(shape, new float[] { 0f }),
            };


            var modelFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri("ms-appx:///Assets/taxiFarePred.onnx"));

            var session = await taxiFarePredModel.CreateFromStreamAsync(modelFile);

            var modelOutput = await session.EvaluateAsync(modelInput);

            var score = modelOutput.Score0.GetAsVectorView();

            btn1.Content = score[0];
        }