A quick introduction to BrainJS

blog
neural-network

#1

BrainJS is seriously cool. It’s an open-source and practical implementation of the Neural Networks in JavaScript.

We have been experimenting with this for a while now and it seems to help us big time. One of our search engine projects Aaron’s Cat is designed to collect technology and design related information from the public domain and make it available for all of us. We are still in the early stages but the idea is very simple, we crawl defined pages first (about 10 million pages), these pages are then scrutinized for quality and focus on technology and design.

We then use the collected information and BrainJS or similar implementation like TensorFlow to train our neural networks. Make them understand and classify better. With that, we can venture freely across WWW and pick quality content which is focussed on technology and design without having to manually intervene.

I just wanted to show you how simple it is to work with BrainJS. You don’t need to be an expert, as long as you know a bit of JavaScript, you can have a lot of fun with this.

Install

npm install brain.js --save

Import

We will use a type of recurrent neural network units called LSTM (Long short-term memory)

// net will be our super neural network
var net = new brain.recurrent.LSTM();

Lets train & Predict

// Here we are training to potentially introduce a new dictionary.
net.train([
  'Creator is a bot or a person that can think, invent, hack, make, produce or bring something into existence.',
  'Technology, the application of scientific knowledge for practical purposes.',
  'cat is the best',
], { log: true });

// Time to predict
var output = net.run('Creator');
console.log(`Creator ${output}`);

Have fun. I will try to post more articles about different systems and neural network types.

Here is the GitHub project for BrainJS.