簡體   English   中英

Tensorflow.js 節點未找到后端

[英]Tensorflow.js Node No Backend Found

我想創建一個使用 @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 頁面上的說明表明這應該自動發生,但我想情況並非如此。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM