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

weblearn

v2.1.0

Published

modular neural networks for node.js and the browser

Downloads

4

Readme

WebLearn makes it super easy to write and train deep neural networks in JavaScript!

Since WebLearn is written completely in JavaScript, you can run the exact same code in the browser with browserify or in node.js.

WebLearn is extremely modular. The core WebLearn package is tiny, but it's been carefully designed to spawn a rich ecosystem of modules and tools. You can drop in new types of layers, visualizations, criteria, etc-- all with a simple require()

We borrow most of our abstractions and API conventions from Torch and Keras. Translating programs written with Torch to run on the web with WebLearn is especially straightforward.

It's basically the WebTorrent or Webcoin of neural networks.

If you're a JavaScript hacker, you may be aware that Deep Learning™ is a big deal, but maybe you've never actually used a neural network. WebLearn is for you. It's just JavaScript-- read the source and watch the mysticism around machine learning disappear. Or just snap together some layers from npm and don't give it a second thought!

AI will belong to the hackers / tinkerers of the world, and there's no larger community of tinkerers than npm / JavaScript users. WebLearn is a hackable-to-the-core pure JavaScript machine learning framework-- go forth and use it in the name of science!

v2.x

In version 2, WebLearn eschews using its own tensor class and instead uses ndarrays and functions that operate on them.

Usage

npm install weblearn
const ndarray = require('ndarray')
const { ReLU, Linear, MSE, SGD, Sequential } = require('weblearn')

let model = Sequential({
  optimizer: SGD(.01),
  loss: MSE()
})

model.add(Linear(2, 20))
  .add(ReLU())
  .add(Linear(20, 1))

// [ input, target ] (both ndarrays)

const data = [
  [ndarray([0, 0]), ndarray([0])],
  [ndarray([0, 1]), ndarray([1])],
  [ndarray([1, 0]), ndarray([1])],
  [ndarray([1, 1]), ndarray([0])]
]
for(let i = 0; i < 1000; i++) {
  model.fit(data, { verbose: false })
}

data.forEach(d => {
  console.log(model.forward(d[0]))
})

Why JavaScript?

JS has some unique advantages for training neural nets:

  • Runtime availability: bundle your neural net into a single .js file and deploy it to your users! No installations, permissions, etc. Let your users bring their own compute to the deep learning-enabled features in your app.

  • Speed: when it comes to doing math on a CPU, JavaScript is actually very fast. It can also talk to the host's GPU to do math there!

  • Portability: you can run the exact same model in your user's browser and on your own servers with node. You can train your net on the client, pass the parameters to the server, and sample from it there. Or vice versa!

  • Community: lots of people know JavaScript and use npm. This makes it easier to develop a healthy ecosystem of WebLearn modules for you to use.

  • Novel architectures: p2p neural networks over WebRTC? Distributed stochastic gradient descent without data ever needing to leave a user's device for increased privacy? Some new kinds of mad science become possible when your neural networks are in JavaScript.

Modules

The main WebLearn package is simply a curated map of useful modules. Most of WebLearn's functionality lives in other modules in repositories listed here.

To add a module to this list, simply publish it on npm as weblearn-{layer,container,criterion,tensor}-yourmodulename and it will appear here when the next version of WebLearn is published.

| name | version | tests | issues | description | |---|---|---|---|---| | weblearn-layer-linear | | | | Simple fully-connected layer | | weblearn-layer-relu | | | | Rectified linear unit non-linearity | | weblearn-layer-sigmoid | | | | Sigmoid activation layer | | weblearn-container-sequential | | | | Compute child layers in sequence | | weblearn-criterion-mse | | | | Mean squared error criterion | | weblearn-tensor | | | | Single-process CPU tensor class | | weblearn-module | | | | Base class for layers | | weblearn-container | | | | Base class for containers | | weblearn-criterion | | | | Base class for criteria |

Writing a module

Check out the Torch docs here and look at WebLearn's Linear layer as an example. More docs coming soon.