# autoencoder

> Autoencoder

Latest version **0.0.3** (published 2021-07-31) · MIT license · 0 weekly downloads

## Install

```sh
npm install autoencoder
pnpm add autoencoder
yarn add autoencoder
bun add autoencoder
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.3 |
| Published | 2021-07-31 |
| First published | 2020-04-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 42.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Anton Zemlyansky |
| Maintainers | zemlyansky |
| Keywords | autoencoder, neural-net |

## Links

- npm: https://www.npmjs.com/package/autoencoder
- Repository: https://github.com/zemlyansky/autoencoder
- Homepage: https://github.com/zemlyansky/autoencoder#readme
- Issues: https://github.com/zemlyansky/autoencoder/issues
- npm.io page: https://npm.io/package/autoencoder

## Dependencies (1)

- [adnn](https://npm.io/package/adnn.md) ^2.0.10

## Alternatives

- [flatbuffers](https://npm.io/package/flatbuffers.md) — 6.0M weekly downloads
- [jwt-simple](https://npm.io/package/jwt-simple.md) — 259.5K weekly downloads
- [@exodus/patch-broken-hermes-typed-arrays](https://npm.io/package/@exodus/patch-broken-hermes-typed-arrays.md) — 28.5K weekly downloads
- [@native-to-anchor/buffer-layout](https://npm.io/package/@native-to-anchor/buffer-layout.md) — 12.2K weekly downloads
- [binary-parser-encoder](https://npm.io/package/binary-parser-encoder.md) — 5.3K weekly downloads

## Recent versions

- 0.0.3 (latest) — 2021-07-31
- 0.0.2 — 2020-04-14
- 0.0.1 — 2020-04-14

## README

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

![Autoencoder](./assets/autoencoder.png)

### Install and load
Install from npm:
```
npm install autoencoder
```

Then load with `require`:
```javascript
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
```javascript
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
```javascript
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
```javascript
ae.fit(X, {
  'batchSize': 100,
  'iterations': 5000,
  'method': 'adagrad', // (default 'adagrad')
  'stepSize': 0.01,
})
```

Optimization methods: `sgd`, `adagrad`, `adam`

### Encode, Decode, Predict
```javascript
const Y = ae.encode(X)
const Xd = ae.decode(Y)
const Xp = ae.predict(X) // Similar to ae.decode(ae.encode(X))
```

### Web demo (dimensionality reduction)

Try the package in the browser on [StatSim Vis](https://statsim.com/vis). Choose a CSV file, change a dimensionality reduction method to **Autoencoder**, then click *Run*.

---
_Source: https://npm.io/package/autoencoder · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
