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 🙏

© 2026 – Pkg Stats / Ryan Hefner

mashtishk

v2.0.0

Published

A complete deep learning library for JavaScript — Dense, CNN, RNN/LSTM/GRU, Attention, GPU acceleration, and ESP32 deployment. By CavyIoT.

Readme

mashtishk

A complete deep learning library for JavaScript. Dense networks, CNN, RNN/LSTM/GRU, Attention, GPU acceleration, and ESP32/IoT deployment — all in one zero-dependency package.

By CavyIoT Private Limited

npm install mashtishk

Architecture

Your Code
    │
    ▼
NeuralNetworkV2 / SequentialModel        ← src/nn/
    │
    ▼
Layer  (Dense, Conv2D, LSTM, GRU, …)     ← src/nn/  +  src/layers/
    │
    ├── Activations  (relu, sigmoid, …)  ← src/activations/
    ├── Losses       (MSE, BCE, CCE, …)  ← src/losses/
    └── Optimizers   (Adam, SGD, …)      ← src/optimizers/
    │
    ▼
Tensor / Matrix engine                   ← src/core/
    │
    ▼
CPU  ──or──  GPU backend (gpu.js)        ← src/gpu/
    │
    ▼
Node.js  ──or──  Browser (dist/mashtishk.min.js)
    │
    ▼
ESP32 / MCU  (via nn.toCCode())          ← src/nn/NeuralNetwork.js

Quick Start

const { NeuralNetworkV2 } = require('mashtishk');

// 1. Build
const nn = new NeuralNetworkV2({
  layers: [
    { inputSize: 2, units: 4, activation: 'relu' },
    { units: 1,               activation: 'sigmoid' }
  ],
  learningRate: 0.01,
  epochs: 500,
  verbose: false
});

// 2. Compile
nn.compile({ optimizer: 'adam', loss: 'binaryCrossEntropy' });

// 3. Fit
const data = [
  { input: [0, 0], output: [0] },
  { input: [1, 0], output: [1] },
  { input: [0, 1], output: [1] },
  { input: [1, 1], output: [0] }   // XOR
];
const history = nn.fit(data);

// 4. Predict
console.log(nn.predict([0, 1]));   // → [0.9978]
console.log(nn.predict([1, 1]));   // → [0.0021]

Running Examples

npm run example:hello        # learn to double a number
npm run example:or           # OR gate — single neuron
npm run example:xor          # XOR — hidden layer required
npm run example:iris         # 3-class iris dataset
npm run example:spam         # binary spam classifier
npm run example:houses       # house price prediction
npm run example:sensor       # time-series sensor forecasting
npm run example:iot          # anomaly detector + ESP32 C export

API Reference

new NeuralNetworkV2(config)

| Option | Type | Default | Description | |---|---|---|---| | layers | Array | required | Layer definitions | | learningRate | number | 0.01 | Step size for weight updates | | epochs | number | 100 | Maximum training iterations | | batchSize | number | 32 | Samples per gradient update | | validationSplit | number | 0.1 | Fraction held out for validation | | earlyStoppingPatience | number | 10 | Stop after N epochs without improvement | | gradientClip | number | 1.0 | Maximum gradient norm | | verbose | boolean | true | Print epoch logs |

Layer definition:

{ inputSize: 4, units: 16, activation: 'relu', init: 'he', dropout: 0.2, batchNorm: true }

inputSize required only on the first layer.

Methods

| Method | Description | |---|---| | nn.compile({ optimizer, loss }) | Wire loss and optimizer | | nn.fit(data) | Train — returns history { loss, valLoss, accuracy } | | nn.predict(input) | Forward pass on one sample | | nn.evaluate(data) | Returns { loss, accuracy } | | nn.summary() | Print architecture and parameter count | | nn.save(path) | Save weights to JSON | | nn.load(path) | Load weights from JSON | | nn.toJSON() | Serialize to plain object | | NeuralNetworkV2.fromJSON(obj) | Restore from serialized object | | nn.toCCode(fnName) | Export as C function for ESP32/MCU | | nn.freeze(layerIndex) | Freeze layer weights (transfer learning) |

Activations

relu · sigmoid · tanh · softmax · linear · leakyRelu · elu · swish

Losses

mse · mae · binaryCrossEntropy · categoricalCrossEntropy · huber · cosineProximity

Optimizers

adam · adamw · sgd · momentum · nag · rmsprop · adagrad · adadelta · adamax · nadam

Advanced Layers

const {
  Conv2D, MaxPool2D, AvgPool2D, Flatten,   // CNN
  RNN, LSTM, GRU, Bidirectional,            // Recurrent
  Attention, MultiHeadAttention,            // Transformer
  PositionalEncoding, Embedding,            // NLP
  LayerNorm, SequentialModel
} = require('mashtishk');

DataUtils

DataUtils.normalise(array)
DataUtils.normaliseBatch(data)
DataUtils.trainTestSplit(data, 0.8)    // → { train, test }
DataUtils.oneHot(labels)               // → { data, classes }
DataUtils.kFold(data, k)               // → array of k folds

Browser Usage

npm install --save-dev browserify terser
npm run build
# → dist/mashtishk.js       (633 KB)
# → dist/mashtishk.min.js   (305 KB)
<script src="dist/mashtishk.min.js"></script>
<script>
  const nn = new NeuralNetworkV2({ ... });
  nn.compile({ optimizer: 'adam', loss: 'mse' });
  nn.fit(data);
</script>

All classes become globals after the script tag: NeuralNetworkV2, DataUtils, Matrix, Tensor, Adam, LSTM, Conv2D


ESP32 / IoT

nn.fit(sensorData);
const fs = require('fs');
fs.writeFileSync('model.h', nn.toCCode('predict'));

Embeds trained weights as C float arrays ready for an Arduino/ESP32 sketch. See examples/iot/esp32-export.js for the full workflow.


GPU

npm install gpu.js   # optional

Detected and used automatically. Falls back to CPU silently if unavailable.


v1 Compatibility

const { NeuralNetwork } = require('mashtishk');
const nn = NeuralNetwork({ inputs: 2, hiddenLayers: 8, outputs: 1 });
nn.trainNetwork(data);
nn.predict([1, 0]);

License

MIT © CavyIoT Private Limited — see LICENSE

Contributing

See CONTRIBUTING.md