我用 npm 安装了@tensorflow-models/knn-classifier,但是当我运行它时出现错误“找不到模块'@tensorflow-models/knn-classifier'”。我可以看到节点模块下的模块,但我仍然收到此错误。其他模型如@tensorflow-models/mobilenet、@tensorflow-models/universal-sentence-encoder 已解决,但 knn-classifier 未解决。这个模型是否需要额外的东西?import * as tf from '@tensorflow/tfjs';import * as knnClassifier from '@tensorflow-models/knn-classifier';const classifier = knnClassifier.create();const trainData = getTrainingData();for(const td of trainData) { classifier.addExample(td.xs, td.label); }
1 回答
达令说
TA贡献1821条经验 获得超6个赞
现在这个包丢失了index.js。这是修复
const tf = require('@tensorflow/tfjs');
const knnClassifier = require('./node_modules/@tensorflow-models/knn-classifier/dist/knn-classifier');
const classifier = knnClassifier.create();
console.log('classifier', classifier)
添加回答
举报
0/150
提交
取消