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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@numrs/wasm

v0.1.23

Published

NumRs WebAssembly bindings for browser and Node.js

Readme

@numrs/wasm

NumRs WASM is the WebAssembly binding for the NumRs numerical engine, bringing high-performance tensor operations and deep learning to the browser and Node.js.

🚀 Features

  • Zero FFI overhead: Direct WASM calls.
  • Deep Learning: Full support for Autograd, Neural Networks, and Optimizers.
  • Universal: Works in Browser (ESM), Node.js, Deno, and Bundlers.
  • TypeScript: Full type definitions included.

📦 Installation

npm install @numrs/wasm

🎯 Usage

🌐 Browser (No Bundler)

To use @numrs/wasm directly in the browser without a bundler (like Vite/Webpack), you must use an Import Map to point to the pkg-web (ES Modules) build.

Add this to your HTML <head>:

<script type="importmap">
{
    "imports": {
        "@numrs/wasm": "./node_modules/@numrs/wasm/pkg-web/numrs_wasm.js"
    }
}
</script>

<script type="module">
    import init, { Tensor, nn } from '@numrs/wasm';

    async function run() {
        await init(); // Initialize the WASM module
        
        console.log("NumRs WASM loaded!");
        
        // Create a tensor
        let x = Tensor.randn([10, 5]);
        
        // Define a model
        let model = new nn.Sequential();
        model.add_linear(new nn.Linear(5, 10));
        model.add_relu(new nn.ReLU());
        model.add_linear(new nn.Linear(10, 2));

        // Forward pass
        let output = model.forward(x);
        console.log("Output shape:", output.shape());
    }

    run();
</script>

📦 Bundlers (Vite, Webpack) & Node.js

import init, { Tensor, Sequential, Linear, ReLU, Trainer } from '@numrs/wasm';

// Initialize WASM
await init(); 

// 1. Define Model
const model = new Sequential();
model.add_linear(new Linear(10, 32));
model.add_relu(new ReLU());
model.add_linear(new Linear(32, 1));

// 2. Training Loop
const trainer = new Trainer(model, "adam", "mse", 0.01);
// Assuming xTrain and yTrain are Tensors
trainer.fit(xTrain, yTrain, 10);

🧠 Optimizers & Loss Functions

NumRs supports a wide range of optimizers and loss functions for training:

| Context | Supported Values | | :------------- | :--------------------------------------------------------------------------------------------------------------------------------------- | | Optimizers | "sgd", "adam", "adamw", "nadam", "radam", "rmsprop", "adagrad", "adadelta", "lamb", "adabound", "lbfgs", "rprop" | | Losses | "mse" (Regression), "cross_entropy" (Classification) |

🔍 Advanced Topics

Time Series (1D CNN)

Use Conv1d for sequence processing. input shape should be [Batch, Channels, Length].

model.add_conv1d(new nn.Conv1d(in_channels, out_channels, kernel_size));
model.add_relu(new nn.ReLU());
model.add_flatten(new nn.Flatten(1, -1));
model.add_linear(new nn.Linear(hidden_size, output_size));

ONNX Support

NumRs WASM can export models to JSON representation compatible with web inference.

  • Export: OnnxModelWrapper.export_model_to_json(...)
  • Inference: OnnxModelWrapper.load_from_json(...)

📚 Documentation

For full API documentation, please refer to the main NumRs Repository or the detailed docs in DOCS.md.

License

AGPL-3.0-only