
Research
PyPI Package Disguised as Instagram Growth Tool Harvests User Credentials
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
@tensorflow/tfjs-backend-webgl
Advanced tools
@tensorflow/tfjs-backend-webgl is a WebGL-accelerated backend for TensorFlow.js, enabling high-performance machine learning computations in the browser. It leverages the power of the GPU to perform operations faster than the CPU backend.
Tensor Operations
This feature allows you to perform tensor operations such as addition, multiplication, etc., using the WebGL backend for accelerated performance.
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-backend-webgl');
async function run() {
await tf.setBackend('webgl');
const a = tf.tensor([1, 2, 3, 4]);
const b = tf.tensor([5, 6, 7, 8]);
const c = a.add(b);
c.print(); // Output: [6, 8, 10, 12]
}
run();
Model Training
This feature allows you to train machine learning models directly in the browser using the WebGL backend for faster computations.
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-backend-webgl');
async function run() {
await tf.setBackend('webgl');
const model = tf.sequential();
model.add(tf.layers.dense({units: 100, activation: 'relu', inputShape: [10]}));
model.add(tf.layers.dense({units: 1}));
model.compile({optimizer: 'sgd', loss: 'meanSquaredError'});
const xs = tf.randomNormal([100, 10]);
const ys = tf.randomNormal([100, 1]);
await model.fit(xs, ys, {epochs: 10});
console.log('Model training complete');
}
run();
Model Inference
This feature allows you to perform model inference, i.e., making predictions using a pre-trained model, with the WebGL backend for improved performance.
const tf = require('@tensorflow/tfjs');
require('@tensorflow/tfjs-backend-webgl');
async function run() {
await tf.setBackend('webgl');
const model = await tf.loadLayersModel('https://example.com/model.json');
const input = tf.tensor([1, 2, 3, 4], [1, 4]);
const output = model.predict(input);
output.print();
}
run();
@tensorflow/tfjs-backend-cpu is a CPU-based backend for TensorFlow.js. It is generally slower than the WebGL backend but can be used in environments where WebGL is not available or desired.
@tensorflow/tfjs-node is a Node.js backend for TensorFlow.js, providing high-performance machine learning computations on the server-side. It leverages the TensorFlow C library for accelerated performance.
gpu.js is a JavaScript library for GPU-accelerated computations. While it is not specifically designed for machine learning, it can be used to perform general-purpose computations on the GPU, similar to the WebGL backend of TensorFlow.js.
This package implements a GPU accelerated WebGL backend for TensorFlow.js.
Note: this backend is included by default in @tensorflow/tfjs
.
// Import @tensorflow/tfjs-core
import * as tf from '@tensorflow/tfjs-core';
// Adds the WebGL backend to the global backend registry.
import '@tensorflow/tfjs-backend-webgl';
<!-- Import @tensorflow/tfjs-core -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core"></script>
<!-- Adds the WebGL backend to the global backend registry -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl"></script>
You can also get ES2017 code using the following links
<!-- Import @tensorflow/tfjs-core -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-core@2.0.0-rc.4/dist/tf-core.es2017.js"></script>
<!-- Adds the WebGL backend to the global backend registry -->
<script src="https://cdn.jsdelivr.net/npm/@tensorflow/tfjs-backend-webgl@2.0.0-rc.4/dist/tf-backend-webgl.es2017.js"></script>
FAQs
GPU accelerated WebGL backend for TensorFlow.js
The npm package @tensorflow/tfjs-backend-webgl receives a total of 192,217 weekly downloads. As such, @tensorflow/tfjs-backend-webgl popularity was classified as popular.
We found that @tensorflow/tfjs-backend-webgl demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 10 open source maintainers 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.
Research
A deceptive PyPI package posing as an Instagram growth tool collects user credentials and sends them to third-party bot services.
Product
Socket now supports pylock.toml, enabling secure, reproducible Python builds with advanced scanning and full alignment with PEP 751's new standard.
Security News
Research
Socket uncovered two npm packages that register hidden HTTP endpoints to delete all files on command.