C# TFException:预期参数[0]为字符串,但提供了浮点(Unity3d)

C# TFException:预期参数[0]为字符串,但提供了浮点(Unity3d),c#,unity3d,tensorflow,tensorflowsharp,C#,Unity3d,Tensorflow,Tensorflowsharp,我正在使用Unity3d中变量的语音命令模型示例: string WAV_INPUT = "wav_data"; string SOFTMAX_NAME = "labels_softmax"; string[] outputScoresNames = new string[] { SOFTMAX_NAME }; 然后向模型添加如下输入: private void recognize(float[] audioFile) { //labe

我正在使用Unity3d中变量的语音命令模型示例:

string WAV_INPUT = "wav_data";
        string SOFTMAX_NAME = "labels_softmax";
        string[] outputScoresNames = new string[] { SOFTMAX_NAME };
然后向模型添加如下输入:

 private void recognize(float[] audioFile)
    {
        //labels_softmax:0 output name 
        //labels wav_data:0 input name from model 
        string WAV_INPUT = "wav_data";
        string SOFTMAX_NAME = "labels_softmax";
        string[] outputScoresNames = new string[] { SOFTMAX_NAME };

        int how_many_labels = 4;
        string[] labels = new string[] { "_silence_" , "_unknown_", "stop","go"};

         TextAsset model = Resources.Load("GoStop") as TextAsset;
         TFGraph  graph = new TFGraph();
         graph.Import(model.bytes);

        TFSession session = new TFSession(graph);

        var runner = session.GetRunner();

        runner.AddInput(graph[WAV_INPUT][0], audioFile);
        runner.AddTarget(outputScoresNames);
        runner.Run();
       // float[] recurrent_tensor = runner.Run()[0].GetValue() as float[];

    }
softmax的例外情况如下:

TFException: Expects arg[0] to be string but float is provided
TensorFlow.TFStatus.CheckMaybeRaise (TensorFlow.TFStatus incomingStatus, System.Boolean last) (at <1fe2de69842a4a4ba15256b83cca05f3>:0)
TensorFlow.TFSession.Run (TensorFlow.TFOutput[] inputs, TensorFlow.TFTensor[] inputValues, TensorFlow.TFOutput[] outputs, TensorFlow.TFOperation[] targetOpers, TensorFlow.TFBuffer runMetadata, TensorFlow.TFBuffer runOptions, TensorFlow.TFStatus status) (at <1fe2de69842a4a4ba15256b83cca05f3>:0)
TensorFlow.TFSession+Runner.Run (TensorFlow.TFStatus status) (at <1fe2de69842a4a4ba15256b83cca05f3>:0)
tensor.recognize (System.Single[] audioFile) (at Assets/tensor.cs:51)
tensor.Start () (at Assets/tensor.cs:23)
TFException:要求arg[0]为字符串,但提供了float
TensorFlow.TFStatus.CheckMaybeRaise(TensorFlow.TFStatus incomingStatus,System.Boolean last)(位于:0)
TensorFlow.TFSession.Run(TensorFlow.TFOutput[]输入,TensorFlow.TFensor[]输入值,TensorFlow.TFOutput[]输出,TensorFlow.TFOperation[]目标器,TensorFlow.TFBuffer运行元数据,TensorFlow.TFBuffer运行选项,TensorFlow.TFStatus状态)(位于:0)
TensorFlow.TFSession+Runner.Run(TensorFlow.TFStatus状态)(位于:0)
tensor.recognize(System.Single[]音频文件)(at Assets/tensor.cs:51)
tensor.Start()(位于Assets/tensor.cs:23)

这是铸造问题吗?如何管理它以与TensorFlowSharp合作

我可以通过简单地将张量中的值转换为字符串来解决这个问题

 graph.Import(model.bytes);
 var session = new TFSession(graph);
 var runner = session.GetRunner();
 TFTensor tft = TFTensor.CreateString(array);
 runner.AddInput(graph[WAV_INPUT][0], tft);
 runner.Fetch(outputScoresNames);
 var output = runner.Run();