Error: The specified module could not be found. \\?\C:\Program Files\nodejs\tf\node_modules\@tensorflow\tfjs-node\lib\napi-v5\tf js_binding.node

天涯浪子 提交于 2020-04-30 07:09:39

问题


I am getting an error when importing '@tensorflow/tfjs-node' module. My problem is similar to that mentioned in Cannot import @tensorflow/tfjs-node in nodejs

TensorFlow.js version- 1.7.3

Platform informations: Windows 8.1 Python 2.7.12 npm 6.14.4 node 10.20.1

Package.json is as follows:
{
  "name": "tf",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC",
  "dependencies": {
    "@tensorflow/tfjs": "^1.7.3",
    "@tensorflow/tfjs-node": "^1.7.3"
  }
}

And the script is a simple one shown below:

console.log("HI");
const tf= require('@tensorflow/tfjs');
require('@tensorflow/tfjs-node');

// Train a simple model:
const model = tf.sequential();
model.add(tf.layers.dense({units: 100, activation: 'relu', inputShape: [10]}));
model.add(tf.layers.dense({units: 1, activation: 'linear'}));
model.compile({optimizer: 'sgd', loss: 'meanSquaredError'});

const xs = tf.randomNormal([100, 10]);
const ys = tf.randomNormal([100, 1]);

model.fit(xs, ys, {
  epochs: 100,
  callbacks: {
    onEpochEnd: (epoch, log) => console.log(`Epoch ${epoch}: loss = ${log.loss}`),
  }
});

Although the file is there already in the path C:\Program Files\nodejs\tf\node_modules@tensorflow\tfjs-node\lib\napi-v5\tf js_binding.node see the image below for your reference.

Need ways to fix it. Thanks.

来源:https://stackoverflow.com/questions/61442632/error-the-specified-module-could-not-be-found-c-program-files-nodejs-tf-n

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!