【问题标题】:TensorflowJS: TypeError: Cannot read property 'fetch' of undefinedTensorflowJS:TypeError:无法读取未定义的属性“获取”
【发布时间】:2019-05-08 19:19:32
【问题描述】:

我有一个 Angular 7 应用程序,我正在尝试按照 this 示例加载 mobilenet 模型。

我通过运行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)

有人知道是什么问题吗?

【问题讨论】:

    标签: javascript angular typescript tensorflow tensorflow.js


    【解决方案1】:

    我发现问题在于我的 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",
    ...
    

    错误消失了。

    【讨论】:

      猜你喜欢
      • 2020-02-14
      • 1970-01-01
      • 2020-12-05
      • 2021-04-14
      • 1970-01-01
      • 1970-01-01
      • 2020-07-23
      • 2021-07-08
      相关资源
      最近更新 更多