JSPM

mlearningjs

0.0.1
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q15775F
  • License MIT

A machine learning module built in JS

Package Exports

  • mlearningjs

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (mlearningjs) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

#mlearning.js

A machine learning library written in JavaScript.

#Usage

First you have to initialize a network

var Network = require('mlearning').Network;

var myNetwork = new Network(50, 250);

The first argument is the size of the input vector. The second number is the size of the batches during training.

Next you can create your network

myNetwork.addLayer(5000, 0.01);
myNetwork.addReLU();
myNetwork.addLayer(2, 0.1);
myNetwork.addReLU();
myNetwork.addSoftmax();
myNetwork.useCrossEntropyLoss();

The above code creates a Deep Neural Network with a hidden layer of size 5000. The output is of size 2. In between each layer is a rectifier linear unit non-linearity. The final layer is a softmax. The loss function the network will use is the cross entropy loss function.

Finally, we can train the network

myNetwork.train(100000, (batchSize) => {
    return {
        X: someInputMatrix,
        Y: someOutputMatrix
    };
}

The network will train for the number of iterations stated using the second parameter as the function to generate the input and expected values.