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 🙏

© 2024 – Pkg Stats / Ryan Hefner

proper-ann

v1.0.6

Published

A simple, lightweight Artificial Neural Network library.

Downloads

17

Readme

proper-ann

Simple and flexible Artificial Neural Network library for JavaScript/Node.js.

Usage

Importing

const ProperANN = require('proper-ann');

Instantiation

let ann = new ProperANN({
  learningRate: .0001,
  layerNodeCounts: [100, 2000, 2000, 100],
  weightDecayFactor: .000001
});

The layerNodeCounts option represents the number of nodes at each layer starting with the input layer, hidden layers and the output layer. There can be an arbitrary number of layers.

Training

  • The number of elements in the inputs and targetOutputs arrays (first and last arguments) must match the number of nodes in the input and output layer respectively (as specified in layerNodeCounts during instantiation).

  • The elements in both inputs and targetOutputs arrays must be numbers (floating point numbers and negatives are supported). The ideal range of numbers (e.g. when encoding strings) depends on the activation function. The default activation function is ELU which works well with small positive numbers between 0 and 5.

  • ELU activation function is prone to exploding gradients, this can lead to NaN values in the outputs. In this case, you may want to reduce the range of numbers that you provide as input - Or you can use an alternative representation for your inputs and outputs; e.g. arrays of 1s and 0s as shown below.

let { loss } = ann.train([1, 1], [0, 0]);

OR

let { loss } = ann.trainBatch([
  [[1, 1], [0, 0]],
  [[1, 0], [0, 1]],
  [[0, 1], [1, 0]]
]);

Inference

let outputs = ann.run([1, 1]);

Custom functions

Many functions which the ANN uses internally can be customized. The default activationFunction is ProperANN.eluActivationFunction and the default activationDerivativeFunction (used to calculate gradients) is ProperANN.eluActivationDerivativeFunction. The ProperANN class exposes a number of static functions which can be used by passing them to the ANN's constructor via the activationFunction and activationDerivativeFunction options during instantiation. It's important that the specified activationFunction and activationDerivativeFunction correspond.

Serializing to and from model files

You can use the proper-ann-serializer module to serialize your trained ANN model to and from the file system like this:

const ProperANNSerializer = require('proper-ann-serializer');

// ...

(async () => {
  let annSerializer = new ProperANNSerializer();

  try {
    // This will look for a directory called my-model.
    await annSerializer.loadFromDir(ann, 'my-model');
  } catch (error) {
    console.log('Could not find an existing ANN model, will start from scratch...');
  }

  // ...

  // Will throw if it fails to save.
  await annSerializer.saveToDir(ann, 'my-model');
})();

Running tests

npm test

License

AGPL by default

By default, this product is issued under AGPL-3.0.

Copyleft exemption for CLSK token holders

If you own 10K CLSK tokens (https://capitalisk.com/), then you are exempt from the AGPL copyleft requirement of making the code of your derived projects public. This exemption applies automatically from the moment that you acquire 10K or more CLSK tokens and it is valid so long as you continue to hold that amount of tokens.

If your CLSK balance falls below 10K, then you will be once again bound to the copyleft conditions of AGPL-3.0 after a grace period of 90 days; after this grace period, your derived project's code must be made public. Timestamps which can be used to prove ownership of CLSK tokens over time are recorded on the Capitalisk blockchain in a decentralized, immutable way so it is important that you hold 10K CLSK throughout your derived project's entire commercial life if you intend to keep the code private.

This exemption also applies to companies; in this case, the total CLSK holdings of the company plus those of its directors and board members must be greater than 10K multiplied by the maximum number of contributors which have worked on the project concurrently since the start of the project (e.g. according to records in the project's code repository). If a company falls out of compliance, the standard 90-day grace period applies before reverting back to the AGPL-3.0 license.

Derived code may optionally be distributed with the same copyleft exemption clause as this project; in this case, the CLSK token ownership requirement must be at least as high as this project.

The amount of CLSK tokens which need to be held to qualify for the copyleft exemption may be revised downwards in the future but never upwards.