Sign Up for Free

RunKit +

Try any Node.js package right in your browser

This is a playground to test code. It runs a full Node.js environment and already has all of npm’s 1,000,000+ packages pre-installed, including autoencoder with all npm packages installed. Try it out:

var autoencoder = require("autoencoder")

This service is provided by RunKit and is not affiliated with npm, Inc or the package authors.

autoencoder v0.0.2

Autoencoder

Autoencoder

A simple autoencoder module for experimentation and dimensionality reduction. Supports automatic scaling

Autoencoder

Install and load

Install from npm:

npm install autoencoder

Then load with require:

const Autoencoder = require('autoencoder')

Create new autoencoder

Autoencoder supports two ways of a model initialization:

  • Provide the number of layers, input size, encoder output size (number of latent variables) and the activation function name
const ae = new Autoencoder({
  'nInputs': 10,
  'nHidden': 2,
  'nLayers': 2, // (default 2) - number of layers in each encoder/decoder
  'activation': 'relu' // (default 'relu') - applied to all, but the last layer
})
  • Define each layer separately for both encoder and decoder
const ae = new Autoencoder({
  'encoder': [
    {'nOut': 10, 'activation': 'tanh'},
    {'nOut': 2, 'activation': 'tanh'}
  ],
  'decoder': [
    {'nOut': 2, 'activation': 'tanh'},
    {'nOut': 10}
  ]
})

Activation functions: relu, tanh, sigmoid

As other neural nets, autoencoder is very sensitive to input scaling. To make it easier the scaling is enabled by default, you can control it with an extra parameter scale that takes true or false

Train autoencoder

ae.fit(X, {
  'batchSize': 100,
  'iterations': 5000,
  'method': 'adagrad', // (default 'adagrad')
  'stepSize': 0.01,
})

Optimization methods: sgd, adagrad, adam

Encode, Decode, Predict

const Y = ae.encode(X)
const Xd = ae.decode(Y)
const Xp = ae.predict(X) // Similar to ae.decode(ae.encode(X))

Metadata

RunKit is a free, in-browser JavaScript dev environment for prototyping Node.js code, with every npm package installed. Sign up to share your code.
Sign Up for Free