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

deeplearning-js

v0.5.2

Published

Deep learning library in JavaScript

Downloads

8

Readme

deeplearning-js

npm v npm dm CircleCI Coverage Status

Intention

deeplearning-js is an open source JavaScript library for deep learning. deeplearning-js provides all JavaScript developers a new way to play around with deep learning models without learning unfamiliar Python, statistics or calculus knowledge.

Getting started

npm install deeplearning-js
yarn add deeplearning-js

API

Normalization

Normalize 1D Array data set.

Support normalization method:

  • minmax: (num - min) / (max - min)
  • zscore: (num - mean) / std

Usage

import { Normalization } from 'deeplearning-js';

expect(Normalization.zscore([1, 2, 3])).toEqual([-1.224744871391589, 0, 1.224744871391589]);
expect(Normalization.minmax([1, 2, 3])).toEqual([0, 0.5, 1]);

initializeParameters

Return initial parameters according to model structure.

Support activation functions:

  • linear
  • relu
  • sigmoid
  • softmax

Usage

const initialParameters = initializeParameters(
  [{
    size: trainingSet.input.shape[0],  // input layer nerouns
  }, {
    size: 56,                          // hidden layer nerouns
    activationFunc: 'relu',            // hidden layer activation function
  }, {
    ...                                // more hidden layers
  }, {
    size: trainingSet.output.shape[0], // output layer nerouns
    activationFunc: 'softmax',         // output layer activation function
  }],
  0,                                   // mean (default: 0)
  1,                                   // variance (default: 1)
  0.01,                                // scale (default: 0.01)
);

Return

{
  W1: number[][],
  b1: number[][],
  ...
  Wl: number[][],
  bl: number[][],
}

train

Return parameters and cost after training for 1 epoch.

Support cost functions:

  • quadratic
  • cross-entropy

Usage

train(
  input: number[][],
  output: number[][],
  parameters: any,
  costFunc: 'quadratic' | 'cross-entropy',
  learningRate: number,
)

Return

{
  parameters: {
    W1: number[][],
    b1: number[][],
    ...
    Wl: number[][],
    bl: number[][],
  },
  cost: number,
}

batchTrain

Return parameters and costs after multiple batches of epochs training.

Usage

batchTrain(
  currentBatch: number,
  totalBatch: number,
  batchSize: number,
  input: number[][],
  output: number[][],
  parameters: any,
  learningRate: number,
  costFunc: 'quadratic' | 'cross-entropy',
  onBatchTrainEnd: (ro: {                    // invoke when each batch training ends
    costs: number[],
    parameters: any
  }, currentBatch: number) => any,
  onTrainEnd: (ro: {                         // invoke when all batches training ends
    costs: number[],
    parameters: any,
  }) => any,
  costs?: number[] = [],
  disableRaf?: boolean = false,
)

Return

batchTrain is a recursive function so please handle intermediate training results in onBatchTrainEnd callback and final training results in onTrainEnd callback.

forwardPropagation

Return predict values based on input data and model parameters.

Usage

const forwardResults = forwardPropagation(input, parameters);
const predict = forwardResults.yHat;

Return

{
  yHat: number[][],                          // predict values
  caches: Cache[],                           // for backPropagation
  activationFuncs: string[],                 // for backPropagation
}