TypeError: tf.dataSync is not a function

TypeError: tf.dataSync is not a function

我收到标题中显示的错误。

一周前这段代码运行良好!

我没有改变任何东西(好吧,至少我注意到了)。

我正在导入 API 2.0.0.

提前谢谢你:)

代码:

async function makePrediction(x) {
    
    // variables
    var tensor = tf.tensor([x]);

    // there is a problem with the conversion
    // using an execute method, feeding the inputs as a dictionary and the outputs names as a list
    let outputs = await model.execute({
        'xTensor': tensor
    },
        ['accuracy/modelPrediction:0']);

    // get value from tensor
    // since we only have one value, we can get it straight away
    const result = tf.dataSync()[0];
    console.log(result);

    // cleanup
    outputs.dispose();
}

错误说明了一切:dataSynctf.tensor 的一个方法。如果输出是张量

,你要做的是调用outputs.dataSync()