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

abot-tensorflow

v0.0.1

Published

TensorFlow Node.js provides idiomatic JavaScript language bindings and a high layer API for Node.js users.

Readme

for Node.js

| NPM | Dependency | Build | Coverage | |-----|------------|-------|----------| |NPM version|Dependency Status|Build Status|Coverage

TensorFlow Node.js provides idiomatic JavaScript language bindings and a high layer API for Node.js users.

Notice: This project is still under active development and not guaranteed to have a stable API. This is especially true because the underlying TensorFlow C API has not yet been stabilized as well.

Installation

$ npm install tensorflow2 --save

Usage

Run a predefined graph

The ability to run a predefined graph is the most basic function for any TensorFlow client library.

Given a GraphDef (or MetaGraphDef) protocol message, be able to create a session, run queries, and get tensor results. This is sufficient for a mobile app or server that wants to run inference on a pre-trained model.

Output the GraphDef binary format from your Python script:

import tensorflow as tf
import os

def main():
  v = tf.Variable(1000, name='my_variable')
  sess = tf.Session()
  tf.train.write_graph(sess.graph_def, tmpdir, 'graph.pb', as_text=False)

And load the graph.pb to your JavaScript runtime:

'use strict';

const tf = require('tensorflow2');
const graph = tf.graph();
const session = tf.session();

graph.load('/path/to/graph.pb');

// load the op by name
const op = graph.operations.get('my_variable/Assign');

// the following outputs the 1000
const res = session.run(op);

Graph construction

At least one function per defined TensorFlow op that adds an operation to the graph. Ideally these functions would be automatically generated so they stay in sync as the op definitions are modified.

'use strict';

const tf = require('tensorflow2');
const graph = tf.graph();

const x = graph.constant([[1, 2], [3, 4]], tf.dtype.float32, [2, 2]);
const w = graph.variable(x);
const y = graph.nn.softmax(graph.matmul(w, w));

const session = tf.session();
const res = session.run(y);

Operations

There are the following operations that we supported in this library.

State

The state is managed by users for saving, restoring machine states.

  • [x] variable Holds state in the form of a tensor that persists across steps. Outputs a ref to the tensor state so it may be read or modified.
  • [x] assign Update 'ref' by assigning 'value' to it. This operation outputs "ref" after the assignment is done. This makes it easier to chain operations that need to use the reset value.

Random

  • [x] randomUniform Outputs random values from a uniform distribution.
  • [x] randomUniformInt Outputs random integers from a uniform distribution.
  • [x] randomGamma Outputs random values from the Gamma distribution(s) described by alpha.
  • [x] randomPoisson Outputs random values from the Poisson distribution(s) described by rate.

Array

  • [x] placeholder A placeholder op for a value that will be fed into the computation.
  • [x] const Returns a constant tensor.
  • [x] reverse Reverses specific dimensions of a tensor.
  • [x] shape Returns the shape of a tensor.
  • [x] rank Returns the rank of a tensor.
  • [x] size Returns the size of a tensor.
  • [x] onehot Returns a one-hot tensor.

Base64

  • [x] encode Encode strings into web-safe base64 format.
  • [x] decode Decode web-safe base64-encoded strings.

Flow

  • [x] switch Forwards data to the output port determined by pred.
  • [x] merge Forwards the value of an available tensor from inputs to output.
  • [x] enter Creates or finds a child frame, and makes data available to the child frame.
  • [x] exit Exits the current frame to its parent frame.
  • [x] abort Raise an exception to abort the process when called.
  • [x] trigger Does nothing and serves as a control trigger for scheduling.

Image

  • [x] decodeJpeg Decode a JPEG-encoded image to a uint8 tensor.
  • [x] encodeJpeg JPEG-encode an image.
  • [x] resizeArea Resize images to size using area interpolation.
  • [x] resizeBicubic Resize images to size using bicubic interpolation.
  • [x] resizeBilinear Resize images to size using bilinear interpolation.
  • [x] resizeNearestNeighbor Resize images to size using nearest neighbor interpolation.
  • [x] randomCorp Randomly crop image.

Audio

  • [x] decodeWav Decode a 16-bit PCM WAV file to a float tensor.
  • [x] encodeWav Encode audio data using the WAV file format.
  • [x] spectrogram Produces a visualization of audio data over time.
  • [x] mfcc Transforms a spectrogram into a form that's useful for speech recognition.

Neural networks

In this module, it implements the following algorithms for representing neural networks.

Tests

$ npm test

License

MIT licensed @ 2017