Gathering detailed insights and metrics for @tensorflow/tfjs-layers
Gathering detailed insights and metrics for @tensorflow/tfjs-layers
Gathering detailed insights and metrics for @tensorflow/tfjs-layers
Gathering detailed insights and metrics for @tensorflow/tfjs-layers
A WebGL accelerated JavaScript library for training and deploying ML models.
npm install @tensorflow/tfjs-layers
Module System
Min. Node Version
Typescript Support
Node Version
NPM Version
18,512 Stars
6,100 Commits
1,935 Forks
327 Watching
467 Branches
368 Contributors
Updated on 27 Nov 2024
TypeScript (80.15%)
JavaScript (8.52%)
C++ (4.51%)
Python (3.77%)
Starlark (1.32%)
HTML (0.92%)
Shell (0.51%)
CSS (0.19%)
Objective-C (0.04%)
Java (0.03%)
Ruby (0.01%)
Batchfile (0.01%)
C (0.01%)
Dockerfile (0.01%)
Cumulative downloads
Total Downloads
Last day
-3.5%
22,604
Compared to previous day
Last week
4.5%
125,980
Compared to previous week
Last month
12.9%
508,699
Compared to previous month
Last year
-19%
5,036,637
Compared to previous year
1
2
TensorFlow.js is an open-source hardware-accelerated JavaScript library for training and deploying machine learning models.
Develop ML in the Browser
Use flexible and intuitive APIs to build models from scratch using the low-level
JavaScript linear algebra library or the high-level layers API.
Develop ML in Node.js
Execute native TensorFlow with the same TensorFlow.js API under the Node.js
runtime.
Run Existing models
Use TensorFlow.js model converters to run pre-existing TensorFlow models right
in the browser.
Retrain Existing models
Retrain pre-existing ML models using sensor data connected to the browser or
other client-side data.
This repository contains the logic and scripts that combine several packages.
APIs:
Backends/Platforms:
If you care about bundle size, you can import those packages individually.
If you are looking for Node.js support, check out the TensorFlow.js Node directory.
Check out our examples repository and our tutorials.
Be sure to check out the gallery of all projects related to TensorFlow.js.
Be sure to also check out our models repository where we host pre-trained models on NPM.
There are two main ways to get TensorFlow.js in your JavaScript project: via script tags or by installing it from NPM and using a build tool like Parcel, WebPack, or Rollup.
Add the following code to an HTML file:
1<html> 2 <head> 3 <!-- Load TensorFlow.js --> 4 <script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs/dist/tf.min.js"> </script> 5 6 7 <!-- Place your code in the script tag below. You can also use an external .js file --> 8 <script> 9 // Notice there is no 'import' statement. 'tf' is available on the index-page 10 // because of the script tag above. 11 12 // Define a model for linear regression. 13 const model = tf.sequential(); 14 model.add(tf.layers.dense({units: 1, inputShape: [1]})); 15 16 // Prepare the model for training: Specify the loss and the optimizer. 17 model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); 18 19 // Generate some synthetic data for training. 20 const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]); 21 const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]); 22 23 // Train the model using the data. 24 model.fit(xs, ys).then(() => { 25 // Use the model to do inference on a data point the model hasn't seen before: 26 // Open the browser devtools to see the output 27 model.predict(tf.tensor2d([5], [1, 1])).print(); 28 }); 29 </script> 30 </head> 31 32 <body> 33 </body> 34</html>
Open up that HTML file in your browser, and the code should run!
Add TensorFlow.js to your project using yarn or npm. Note: Because
we use ES2017 syntax (such as import
), this workflow assumes you are using a modern browser or a bundler/transpiler
to convert your code to something older browsers understand. See our
examples
to see how we use Parcel to build
our code. However, you are free to use any build tool that you prefer.
1import * as tf from '@tensorflow/tfjs'; 2 3// Define a model for linear regression. 4const model = tf.sequential(); 5model.add(tf.layers.dense({units: 1, inputShape: [1]})); 6 7// Prepare the model for training: Specify the loss and the optimizer. 8model.compile({loss: 'meanSquaredError', optimizer: 'sgd'}); 9 10// Generate some synthetic data for training. 11const xs = tf.tensor2d([1, 2, 3, 4], [4, 1]); 12const ys = tf.tensor2d([1, 3, 5, 7], [4, 1]); 13 14// Train the model using the data. 15model.fit(xs, ys).then(() => { 16 // Use the model to do inference on a data point the model hasn't seen before: 17 model.predict(tf.tensor2d([5], [1, 1])).print(); 18});
See our tutorials, examples and documentation for more details.
We support porting pre-trained models from:
Please refer below :
TensorFlow.js is a part of the TensorFlow ecosystem. For more info:
tfjs
tag on the TensorFlow Forum.Thanks, BrowserStack, for providing testing support.
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
all changesets reviewed
Reason
GitHub workflow tokens follow principle of least privilege
Details
Reason
license file detected
Details
Reason
binaries present in source code
Details
Reason
5 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 4
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
project is not fuzzed
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Reason
110 existing vulnerabilities detected
Details
Score
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More