如何在tensorflow js中使用预测
how to use predict in tensorflow js
我在python做了个模型,导出到tensorflow js。
该模型正在将面部图像分类为情绪,应该有7类。
我从图像中制作了一个张量并像这样使用预测:
const prediction = model.predict(imageTensor);
我的预测是:
Tensor {
"dataId": Object {},
"dtype": "float32",
"id": 415,
"isDisposedInternal": false,
"kept": false,
"rankType": "2",
"scopeId": 197,
"shape": Array [
1,
7,
],
"size": 7,
"strides": Array [
7,
],
}
如何从这里提取结果?
预测是一个张量。如果要访问数据,则需要使用prediction.dataSync()
找到了答案,我正在使用打字稿并且需要它:
const 预测 = (model.predict(
图像张量
) 作为 tf.Tensor).dataSync();
我在python做了个模型,导出到tensorflow js。 该模型正在将面部图像分类为情绪,应该有7类。
我从图像中制作了一个张量并像这样使用预测:
const prediction = model.predict(imageTensor);
我的预测是:
Tensor {
"dataId": Object {},
"dtype": "float32",
"id": 415,
"isDisposedInternal": false,
"kept": false,
"rankType": "2",
"scopeId": 197,
"shape": Array [
1,
7,
],
"size": 7,
"strides": Array [
7,
],
}
如何从这里提取结果?
预测是一个张量。如果要访问数据,则需要使用prediction.dataSync()
找到了答案,我正在使用打字稿并且需要它: const 预测 = (model.predict( 图像张量 ) 作为 tf.Tensor).dataSync();