我正在尝试将预测系统构建到 MERN 应用程序中。我是 Tensorflow 的新手,刚刚关注 this获取马力与每加仑英里数之间关系的教程。
https://codelabs.developers.google.com/codelabs/tfjs-training-regression/index.html#6
我不明白如何利用它来获得预测值。如何在输入字段中输入马力并获得预测的 MPG。
const xs = tf.linspace(0, 1, 100);
const preds = model.predict(xs.reshape([100, 1]));
我猜上面的线用于绘制从低到高的马力范围。但是我如何获得输入值的预测值?
请帮忙
最佳答案
给定模型,特征是二维数据。
如果你有一个输入字段值,你可以通过使用找到它的预测
const tensor = model.predict(tf.tensor([valueOfInput], [1, 1]))
// Get the value
const value = tensor.dataSync()[0]
关于javascript - 如何在 Tensorflow.js 中获取预测值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57115214/