javascript - Tensorflow.js 节点未找到后端
问题描述
我想创建一个使用 @tensorflow-models/qna 库的 Discord 机器人,但我已经收到相同的错误 4 小时了,但没有任何进展。当我尝试运行此脚本时:
const qna = require('@tensorflow-models/qna');
(async () => {
const passage = "Google LLC is an American multinational technology company that specializes in Internet-related services and products, which include online advertising technologies, search engine, cloud computing, software, and hardware. It is considered one of the Big Four technology companies, alongside Amazon, Apple, and Facebook. Google was founded in September 1998 by Larry Page and Sergey Brin while they were Ph.D. students at Stanford University in California. Together they own about 14 percent of its shares and control 56 percent of the stockholder voting power through supervoting stock. They incorporated Google as a California privately held company on September 4, 1998, in California. Google was then reincorporated in Delaware on October 22, 2002. An initial public offering (IPO) took place on August 19, 2004, and Google moved to its headquarters in Mountain View, California, nicknamed the Googleplex. In August 2015, Google announced plans to reorganize its various interests as a conglomerate called Alphabet Inc. Google is Alphabet's leading subsidiary and will continue to be the umbrella company for Alphabet's Internet interests. Sundar Pichai was appointed CEO of Google, replacing Larry Page who became the CEO of Alphabet."
const question = "Who is the CEO of Google?"
const model = await qna.load();
const answers = await model.findAnswers(question, passage);
console.log(answers);
})();
它给了我以下错误:
(node:16340) UnhandledPromiseRejectionWarning: Error: No backend found in registry.
我试过安装几十个不同版本的 tensorflow 及其后端“tfjs-backend-cpu”。但似乎没有任何效果,我在谷歌上找到的现有答案都没有任何帮助。有人知道如何让该代码在 Node 14 上运行吗?
解决方案
尝试添加:
require('@tensorflow/tfjs-core'); /* or @tensorflow/tfjs-node */
require('@tensorflow/tfjs-backend-cpu');
到文件的顶部。tfjs -backend-cpu NPM 页面上的说明表明这应该是自动发生的,但我想情况并非如此。
推荐阅读
- azure-data-factory - 无法使用事件触发器主体中的表达式语言函数
- python - 从列表 PSAW python 中搜索包含任何单词的 reddit 评论
- html - Firefox 不显示内联 pdf
- function - 有没有一种方法可以返回一种可以拥有多个数量的乐趣?
- javascript - 将状态映射到道具返回未定义且不更新
- f# - F# 我可以在数组上使用负索引吗?(就像在 Python 中一样)?
- svnsync - svnsync 与源存储库密码
- c# - 如何使人物面对行进方向?
- android - SQLite:每秒插入 1 个值还是每分钟插入多个值?
- python - 如何对作为完成模型中外键的特定客户端的所有完成求和?