Eva*_*ows 10 javascript node.js promise tensorflow
我刚刚Tensorflow Toxicity classifier从这个Github 页面的示例中加载了样板代码。
这是代码index.js-
const toxicity = require('@tensorflow-models/toxicity');
const threshold = 0.9;
toxicity.load(threshold).then((model) => {
const sentences = ['you suck'];
model.classify(sentences).then((predictions) => {
console.log(predictions);
});
});
Run Code Online (Sandbox Code Playgroud)
如果你需要完整的项目,这里是GitHub repo。
但是当我运行代码时,它给了我以下错误 -
(node:2180) UnhandledPromiseRejectionWarning: FetchError: request to https://storage.googleapis.com/tfjs-models/savedmodel/universal_sentence_encoder/vocab.json failed, reason: Client network socket disconnected before secure TLS connection was established
at ClientRequest.<anonymous> (D:\xampp\htdocs\nodejs-projects\simple-node\node_modules\node-fetch\lib\index.js:1393:11)
at ClientRequest.emit (events.js:310:20)
at TLSSocket.socketErrorListener (_http_client.js:426:9)
at TLSSocket.emit (events.js:310:20)
at emitErrorNT (internal/streams/destroy.js:92:8)
at emitErrorAndCloseNT (internal/streams/destroy.js:60:3)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:2180) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
(node:2180) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
Run Code Online (Sandbox Code Playgroud)
我在谷歌上查了一些错误,有很多这样的问题,但没有有效的答案。
这是我已经完成的一些事情来消除可能的问题 -
附加信息 -
操作系统:Windows 10(64 位)(1909 版)节点版本:v12.16.3
任何帮助将非常感激。
上面的代码在我的电脑上运行良好。首先运行此命令重试
npm install @tensorflow/tfjs @tensorflow-models/toxicity
Run Code Online (Sandbox Code Playgroud)
发布您可以运行此代码的帖子
const toxicity = require('@tensorflow-models/toxicity');
const threshold = 0.9;
toxicity.load(threshold).then((model) => {
const sentences = ['you suck'];
model.classify(sentences).then((predictions) => {
console.log(predictions);
});
});
Run Code Online (Sandbox Code Playgroud)
有时模块可能没有完全安装它的依赖项。删除您当前的 node_modules 并重试。
如果以上方法都行不通。检查您的节点版本。使用 TLS https://github.com/nodejs/node/issues/21088 的节点 10.1.0 中存在错误
更新您的节点版本并尝试
| 归档时间: |
|
| 查看次数: |
3868 次 |
| 最近记录: |