otk*_*otk 5 javascript node.js tensorflow tensorflow.js
我正在关注本教程:https : //codelabs.developers.google.com/codelabs/tfjs-training-classfication/index.html#2
我已经设置了一个本地 HTTP 服务器,并且可以正常工作并且应用程序正在运行。但是,当我尝试执行第 3 步(加载数据)时,加载数据时出现以下错误:
Uncaught TypeError: Failed to resolve module specifier "@tensorflow/tfjs". Relative references must start with either "/", "./", or "../".
Run Code Online (Sandbox Code Playgroud)
如果我注释掉导入语句:
import * as tf from '@tensorflow/tfjs';
Run Code Online (Sandbox Code Playgroud)
该页面实际加载并显示带有 16 位手写数字的侧边栏。
是否加载了 TensorFlow,我不需要这个导入语句?
或者也许最重要的是,为什么导入不起作用?
如果 tfjs 库作为模块加载,则无需导入它们
\n\n在 html 文件中放入:
\n\n<html>\n<meta content="text/html;charset=utf-8" http-equiv="Content-Type">\n\n<head>\n ...\n <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs@1.5.2"></script>\n <script type="module" src="YOUR_CODE.js"></script>\n ...\n</head>\n\xe2\x80\x8b\n\n<body>\n ...\n</body>\n\xe2\x80\x8b\n\n</html>\nRun Code Online (Sandbox Code Playgroud)\n\n在 YOUR_CODE.js 中简单地说:
\n\nasync function testModel() {\n const model = await tf.loadGraphModel(...);\n ...\n model.execute(pic);\n ...\n}\n\n\ntestModel();\nRun Code Online (Sandbox Code Playgroud)\n
| 归档时间: |
|
| 查看次数: |
1619 次 |
| 最近记录: |