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

@tangent.to/nn

v0.1.1

Published

Neural networks on the tangent tape: a functional layer API (branches, dropout, concrete dropout) differentiated by @tangent.to/grad, trained with @tangent.to/opt, exportable as JSON.

Readme

@tangent.to/nn

Neural networks on the tangent tape. A functional layer API in the spirit of Keras, with branches, dropout and concrete dropout, differentiated by grad, trained with opt's update rules, seeded by proba, whose densities are the likelihood losses; exportable as one JSON file for an app.

import nn from "@tangent.to/nn";

const x    = nn.input(37);                              // 24 soil + 12 tissue + cycle
const soil = nn.dense(32, { activation: "relu" })(nn.slice(x, 0, 24));
const leaf = nn.dense(16, { activation: "relu" })(nn.slice(x, 24, 12));
const h    = nn.concreteDropout(nn.dense(32, { activation: "tanh" }))(
               nn.concat([soil, leaf, nn.slice(x, 36, 1)]));
const out  = nn.dense(2)(h);                              // [mean, log sd]

const model = nn.model(x, out, { loss: "gaussianNLL", normalizeY: true, seed: 42 });
await model.fit(X, y, {
  epochs: 300, batchSize: 32, validationSplit: 0.1,
  callbacks: [nn.callbacks.earlyStopping({ patience: 20 })],
  onEpochEnd: (epoch, logs) => console.log(epoch, logs.valLoss),
});

model.predict(Xnew);                       // point prediction, dropout off
model.predict(Xnew, { samples: 200 });     // { mean, std, epistemic, aleatoric }
model.predict(Xnew, { returnStd: true });  // the noise column alone
model.predictGradient(xnew);               // d mean / d x, as the GP gives it
JSON.stringify(model);                     // architecture + weights, for an app

What is in it

Layers. input(d), dense(units, { activation, useBias, init }) with linear, relu, tanh, sigmoid, softplus, elu, gelu or a function of the Var; concat, slice, add (a residual connection); dropout(rate); concreteDropout(denseLayer, { perFeature, temperature, priorLengthScale }), which learns its rate, one per input feature with perFeature, a relevance per variable; lambda(fn), the escape hatch, a function of the input Var in grad ops. A layer applied twice shares its weights.

Losses. mse, mae, huber(delta), and the likelihood losses over proba's densities: gaussianNLL on a [mean, log sd] output, studentTNLL({ nu }) for robust regression, poissonNLL on a log-rate for counts, binaryCrossEntropy on a logit. Every loss takes (yPred, yTrue, w), a weight per row: sampleWeight in fit is how a missing target is left out.

fit. Asynchronous, yielding every epoch (fitSync for a synchronous caller); adam, sgd, momentum, rmsprop by mini-batch, or lbfgs on the full batch with the tape's exact gradient, which on a few hundred rows is the right tool. normalizeY, validationSplit or validationData, metrics, clipNorm, an AbortSignal, earlyStopping that restores the best weights, a learning-rate schedule, and a non-finite loss that says what usually causes it.

Around the model. clone() for a cross-validation fold or a bootstrap refit; ensemble(model, X, y, { members }); checkGradients(model, X, y) for whoever writes a loss or a lambda layer; summary(); toJSON and fromJSON.

The design note, docs/DESIGN-0.1.md, records why this is a package of its own, what it borrows from the rest of the suite, the two grad releases it depends on, and the order of work.

Where it stops

Rank two: matrices and vectors, so dense networks. Recurrent and convolutional layers, normalization layers and a multiclass softmax wait for grad 0.4 (reductions by axis, a column broadcast, gather); see section 7 of the note. No GPU. Monte Carlo dropout's intervals are not calibrated on their own; the model reports the epistemic and aleatoric parts so a conformal factor from held-out residuals can be applied, and ensemble is the better default when five fits are affordable.

Part of the tangent suite. GPL-3.0, like mc and ds.