TensorflowJS: TypeError: Cannot read property 'fetch' of undefined
TensorflowJS: TypeError: Cannot read property 'fetch' of undefined
我有一个 angular 7 应用程序,我正在尝试按照 this 示例加载移动网络模型。
我通过 运行 npm install @tensorflow/tfjs
(按照 this 说明)安装了 tensorflowjs,通过 运行 @tensorflow-models/mobilenet
.
安装了 mobilenet 模型
之后我通过以下操作导入了移动网络:
import * as mobilenet from '@tensorflow-models/mobilenet';
并执行以下代码以加载模型:
mobilenet.load().then(() => {
obs.next();
}).catch((err) => {
console.log(err);
console.log("ERROR");
});
但我收到以下错误:
TypeError: Cannot read property 'fetch' of undefined
at new e (tf-core.esm.js:17)
at browserHTTPRequest (tf-core.esm.js:17)
at httpRequestRouter (tf-core.esm.js:17)
at tf-core.esm.js:17
at Array.forEach (<anonymous>)
at Function.e.getHandlers (tf-core.esm.js:17)
at Function.e.getLoadHandlers (tf-core.esm.js:17)
at Object.getLoadHandlers (tf-core.esm.js:17)
at e.findIOHandler (tf-converter.esm.js:17)
at e.<anonymous> (tf-converter.esm.js:17)
有人知道问题出在哪里吗?
我发现问题是我的 packade.json.
上的 @tensorflow/tfs 和 @tensorflow/tfjs-core 有不同的版本
所以,我更改了我的包配置:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.0.2",
...
收件人:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.1.2",
...
然后错误消失了。
我有一个 angular 7 应用程序,我正在尝试按照 this 示例加载移动网络模型。
我通过 运行 npm install @tensorflow/tfjs
(按照 this 说明)安装了 tensorflowjs,通过 运行 @tensorflow-models/mobilenet
.
之后我通过以下操作导入了移动网络:
import * as mobilenet from '@tensorflow-models/mobilenet';
并执行以下代码以加载模型:
mobilenet.load().then(() => {
obs.next();
}).catch((err) => {
console.log(err);
console.log("ERROR");
});
但我收到以下错误:
TypeError: Cannot read property 'fetch' of undefined
at new e (tf-core.esm.js:17)
at browserHTTPRequest (tf-core.esm.js:17)
at httpRequestRouter (tf-core.esm.js:17)
at tf-core.esm.js:17
at Array.forEach (<anonymous>)
at Function.e.getHandlers (tf-core.esm.js:17)
at Function.e.getLoadHandlers (tf-core.esm.js:17)
at Object.getLoadHandlers (tf-core.esm.js:17)
at e.findIOHandler (tf-converter.esm.js:17)
at e.<anonymous> (tf-converter.esm.js:17)
有人知道问题出在哪里吗?
我发现问题是我的 packade.json.
上的 @tensorflow/tfs 和 @tensorflow/tfjs-core 有不同的版本所以,我更改了我的包配置:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.0.2",
...
收件人:
...
"@tensorflow/tfjs": "^1.1.2",
"@tensorflow/tfjs-core": "^1.1.2",
...
然后错误消失了。