Security News
Research
Supply Chain Attack on Rspack npm Packages Injects Cryptojacking Malware
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
abot-tensorflow
Advanced tools
TensorFlow Node.js provides idiomatic JavaScript language bindings and a high layer API for Node.js users.
NPM | Dependency | Build | 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.
$ npm install tensorflow2 --save
The ability to run a predefined graph is the most basic function for any TensorFlow client library.
Given a
GraphDef
(orMetaGraphDef
) 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);
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);
There are the following operations that we supported in this library.
The state is managed by users for saving, restoring machine states.
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.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.randomUniform
Outputs random values from a uniform distribution.randomUniformInt
Outputs random integers from a uniform distribution.randomGamma
Outputs random values from the Gamma distribution(s) described by alpha.randomPoisson
Outputs random values from the Poisson distribution(s) described by rate.placeholder
A placeholder op for a value that will be fed into the computation.const
Returns a constant tensor.reverse
Reverses specific dimensions of a tensor.shape
Returns the shape of a tensor.rank
Returns the rank of a tensor.size
Returns the size of a tensor.onehot
Returns a one-hot tensor.encode
Encode strings into web-safe base64 format.decode
Decode web-safe base64-encoded strings.switch
Forwards data
to the output port determined by pred
.merge
Forwards the value of an available tensor from inputs
to output
.enter
Creates or finds a child frame, and makes data
available to the child frame.exit
Exits the current frame to its parent frame.abort
Raise an exception to abort the process when called.trigger
Does nothing and serves as a control trigger for scheduling.decodeJpeg
Decode a JPEG-encoded image to a uint8 tensor.encodeJpeg
JPEG-encode an image.resizeArea
Resize images
to size
using area interpolation.resizeBicubic
Resize images
to size
using bicubic interpolation.resizeBilinear
Resize images
to size
using bilinear interpolation.resizeNearestNeighbor
Resize images
to size
using nearest neighbor interpolation.randomCorp
Randomly crop image
.decodeWav
Decode a 16-bit PCM WAV file to a float tensor.encodeWav
Encode audio data using the WAV file format.spectrogram
Produces a visualization of audio data over time.mfcc
Transforms a spectrogram into a form that's useful for speech recognition.In this module, it implements the following algorithms for representing neural networks.
softmax
Computes softmax activations.l2loss
L2 Loss, Computes half the L2 norm of a tensor without the sqrt
.lrn
Local Response Normalization. The 4-D input
tensor is treated as a 3-D array of 1-D vectors (along the last dimension), and each vector is normalized independently. Within a given vector, each component is divided by the weighted, squared sum of inputs within depth_radius
. For details, see Krizhevsky et al., ImageNet classification with deep convolutional neural networks (NIPS 2012).relu
Computes rectified linear: max(features, 0)
.elu
Computes exponential linear: exp(features) - 1
if < 0, features
otherwise. See Fast and Accurate Deep Network Learning by Exponential Linear Units (ELUs).inTopK
Says whether the targets are in the top K
predictions.$ npm test
MIT licensed @ 2017
FAQs
TensorFlow Node.js provides idiomatic JavaScript language bindings and a high layer API for Node.js users.
The npm package abot-tensorflow receives a total of 1 weekly downloads. As such, abot-tensorflow popularity was classified as not popular.
We found that abot-tensorflow demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.
Security News
Sonar’s acquisition of Tidelift highlights a growing industry shift toward sustainable open source funding, addressing maintainer burnout and critical software dependencies.