tensorflowjs 模块无法正确编译

tensorflowjs 模块无法正确编译
$ npm show @tensorflow/tfjs version
$ 1.0.0
$ npm show typescript version
$ 3.4.3

当我编译项目时ng serve,总是出现以下错误:

ERROR in node_modules/@tensorflow/tfjs- 
core/dist/io/browser_files.d.ts(24,34): error TS1039: Initializers are not 
allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/browser_http.d.ts(23,31): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/indexed_db.d.ts(31,34): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/local_storage.d.ts(41,34): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-data/dist/dataset.d.ts(235,39): error TS1039: 
Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(29,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(48,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(56,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(64,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(69,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(77,33): error 
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(85,33): error 
TS1039: Initializers are not allowed in ambient contexts.

为什么还有另一个tensorflow模块:

$npm show tensorflow version
$0.7.0

答案1

我遇到了同样的问题。我相信这是 tensorflowjs 最新版本的问题。我使用以下版本可以正常工作。

"@tensorflow-models/coco-ssd": "0.1.1",
"@tensorflow/tfjs": "0.14.0",
"rxjs": "6.0.0",
"typescript": "~2.7.2"

相关内容