How to build a simple neural network

Original article was published on Artificial Intelligence on Medium


Create Folder

Create a folder called simpleAi

Create project

Create a file within this folder called app.js

Open Terminal or Command Prompt

Type the command cd [folder path] (replace [folder path] with the path to your project folder)

Install brain.js

Within command prompt or terminal run the following command.

Building the model

Inside of app.js import brain.js and define the initial model.

We will use an LSTM neural network for this.

Long short-term memory (LSTM) is an artificial recurrent neural network (RNN) architecture[1] used in the field of deep learning. Unlike standard feedforward neural networks, LSTM has feedback connections. It can not only process single data points (such as images), but also entire sequences of data (such as speech or video). For example, LSTM is applicable to tasks such as unsegmented, connected handwriting recognition,[2] speech recognition[3][4] and anomaly detection in network traffic or IDS’s (intrusion detection systems).

Setup the training configuration

This is basically the settings that the model uses when training.

Define training data

This is where you can add training data that is used when training your model.

Train the model

Here we train the model on the training data above. You can add your own inputs and outputs to see how this works for you.

Test the trained model with an example input

Test with an unknown input


AI can be used for a lot of useful things. This is just one simple example out of many that can be useful. You can take the example above and put your own spin on things. Maybe you want it to detect someone’s mood based on messages? If you want to get creative you can train it to have a conversation by making the outputs responses. I hope this is helpful to any beginners out there who are wanting to experiment with artificial intelligence.