gpt4 book ai didi

javascript - Brain js NaN 当预测是单词组合是一个完整的句子时

转载 作者:行者123 更新时间:2023-12-02 23:38:31 25 4
gpt4 key购买 nike

我是 Brain js 的新手,我试图让它预测单词的组合是否是一个完整的句子。 https://codepen.io/AtanasBobev/pen/zQzZrP?editors=0010

    const config = {
hiddenLayers: [3]
};

const net = new brain.NeuralNetwork(config);

net.train([{input: ["Hello, I'm John Walker."], output: [1]},
{input: ["This is on you!"], output: [1]},
{input: ["Who are you?"], output: [1]},
{input: ["Let's go."], output: [1]},
{input: ["John kik"], output: [0]},
{input: ["This is"], output: [0]}
]);

const output = net.run(["I'm Stil."]);

alert(output);
//Output: NaN

我知道数据不足以进行良好的预测,但我仍然期望一个介于 0-1 之间的值。可能是什么问题?

最佳答案

这可以通过 Brain 的 LSTM 函数来完成。这是它在您的数据集上的运行情况(还有一些要训练的示例):

const net = new brain.recurrent.LSTM();

net.train([
{ input: "Hello, I'm John Walker.", output: "complete" },
{ input: "This is on you!", output: "complete" },
{ input: "John kik", output: "incomplete" },
{ input: "This is", output: "incomplete" },
{ input: "Great job.", output: "complete" },
{ input: "When I hear a", output: "incomplete" }
]);

输出:

> net.run("I'm Stil.");
"incomplete"
> net.run("Great job!")
"complete"

LSTM docs

关于javascript - Brain js NaN 当预测是单词组合是一个完整的句子时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56191600/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com