我正在尝试将TensorFlow.js用于JavaScript项目中的数组操作。我正在使用import * as tf from '@tensorflow/tfjs';
看来yarn install tensorflow
需要Python 2.7,所以我改用yarn add tensorflow/tfjs
安装所需的Tensorflow.js的子集。这似乎有效,但是当我完成yarn run serve
时,我收到了以下消息:
ERROR Failed to compile with 1 errors
This dependency was not found:
* @tensorflow/tfjs in ./node_modules/cache-loader/dist/cjs.js??ref--12-0!./node_modules/babel-loader/lib!./node_modules/cache-loader/dist/cjs.js??ref--0-0!./node_modules/vue-loader/lib??vue-loader-options!./src/components/DetectorPlot.vue?vue&type=script&lang=js&
To install it, you can run: npm install --save @tensorflow/tfjs
在yarn.lock
之后的yarn add tensorflow/tfjs
中,我看到:
"@tensorflow/tfjs@github:tensorflow/tfjs":
version "1.1.0"
resolved "https://codeload.github.com/tensorflow/tfjs/tar.gz/74b4edef368aa39decc6073af735f81d112bafd8"
dependencies:
"@tensorflow/tfjs-converter" "1.1.0"
"@tensorflow/tfjs-core" "1.1.0"
"@tensorflow/tfjs-data" "1.1.0"
"@tensorflow/tfjs-layers" "1.1.0"
答案 0 :(得分:0)
感谢朋友,我有一个解决方法:
yarn remove @tensorflow/tfjs
和
yarn add @tensorflow/tfjs
我猜它在第一次尝试安装tensorflow失败时进入了一个奇怪的状态。 (令人沮丧的答案是“关闭并重新打开”的频率)...