npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

simpleai

v1.0.11

Published

A lib to make making neural networks as easy as possible.

Readme

A simple AI library.

So, my goal in making this library was to super simple to use. I didn't want someone to be put of playing with AI because they were put off by the tutorials they found online and weren't able to understand the content and/or couldn't make sense of the code samples. Discord

Who is this for?

I intend this library to be for not only people who are new to AI but also for people who are more experienced with AI. In version these current versions it only runs on the CPU but I would like to also add a GPU mode either with gpu.js or gl compute shaders.

So how do I use this library?

When I say that this library is easy to use, I really mean it. With only five lines of code you can have a fully working neural network.

let simpleAI = require("simpleai");
let nn = new simpleAI(); // 1 Make the neural net object
nn.setLayerSizes([2,3,2]); // 2 Set the layer sizes
nn.build(); // 3 build the net
nn.randomizeWeights(); // 4 randomize the weights
nn.randomizeBiases(); // 5 randomize the biases
console.log(nn.predict([1,0]));

You say this is a simple library what if I want customizability!

One of the things that I had in mind when making this library was customizability, so I have included many ways to change the way that the neural network works by modifying functions via some methods. See documentation

Documentation

I am going to go through the recommended functions in the order that you should use them then the unrecommended. You will need to have made your simpleAI object before running these functions. Feel free to ask in the discord too, I love to help.

setLayerSizes()

Optional but strongly recommended This function sets the layer sizes of the neural network. It expects an array which has two or more whole numbers. Each entry specifies how many nodes each layer has.

nn.setLayerSizes([2,3,2]);

build()

This function creates the layers and node objects inside your nn object

nn.build()

randomizeWeights()

This function sets the weights in the neural network

nn.randomizeWeights();

randomizeBiases()

This function sets the biases in the neural network

nn.randomizeBiases();

predict()

This function calculates all the values of the nodes and returns the values of the last layer. This function expects an array that is the same size as the first layer

nn.predict([0,1]);

evolve()

This function chooses one of the weights or biases and either adds or subtracts an amount specified by the training random, by default this is 100 / (Math.random() - 0.5). This function also requires an input from 0 to 1 to set the boundary of choice for whether to modify a bias or weight. 0.8 should be good.

nn.evolve(0.8);

Optional functions

I am not going to give support for using these, you should not need to use these.

setActivationFunction()

Used before predict()

nn.setActivationFunction((x) => {return Math.sin(x*3)});

setWeightsRandom()

Used before randomizeWeights()

nn.setWeightsRandom(() => {return Math.random()});
// I recommend this being between 0 and 1

setBiasRandom()

Used before randomizeWeights()

nn.setBiasRandom(() => {return Math.random()});
// I recommend this being between 0 and 1

setTrainingRandom()

Used before evolve()

nn.setTrainingRandom(() => {return 100 / (Math.random() - 0.5)});
// I recommend this being between -0.005 and 0.005

Can I use this in the browser?

In versions 1.0.0 to 1.0.10 I supplied in the npm package a es6 module for this library however, due to the poor support of es6 modules in general :( so I have decided not to include a browser version until a proper solution can be made.