Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Brain.js to detect bad words #931

Open
Bhargav230m opened this issue Mar 11, 2024 · 2 comments
Open

Brain.js to detect bad words #931

Bhargav230m opened this issue Mar 11, 2024 · 2 comments

Comments

@Bhargav230m
Copy link

Hey there i wanted to train a model to detect badwords, i have tried downloading brain.js to train a model. I have my badwords dataset in json file. I wanted to know if i am going the right track .

import brain from "brain.js";
import fs from "fs";

const a = [];
try {
  const data = fs.readFileSync("BadWord.json", "utf8");
  const parsedData = JSON.parse(data);
  parsedData.known_links.forEach((word) => {
    a.push({ input: word, output: true });
  });

  const net = new brain.recurrent.RNN();
  net.train(a, {
    log: true,
    iterations: 5000,
    learningRate: 0.0001
  });

  const netData = net.toJSON();
  fs.writeFileSync("model.json", netData);

  const b = net.run("goodWord");
  console.log("Result of running model " + b);
} catch (err) {
  console.error(err);
}
@Bhargav230m
Copy link
Author

I had tried learning rate 0.001 earlier but that resulted in Infinity Training error.

Currently my training error is at 0.03

@robertleeplummerjr
Copy link
Contributor

You should really use a LSTM or a GRU for that type of problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants