Tensorflow.js is an open-source library that is developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment. The .engine() function is used to return the global engine which saves the path of every single tensor as well as backends.
Syntax:
tf.engine()
Parameters: This method does not hold any parameter.
Return Value: It returns Engine.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.engine().startScope();
const res = tf.ones([200, 250]);
console.log(res);
|
Output: Here, the scope is not ended so a tensor is returned.
Tensor
[[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
...,
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1],
[1, 1, 1, ..., 1, 1, 1]]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.engine().startScope();
const t1 = tf.ones([200, 250]);
const t2 = tf.tidy(() => t1.min());
tf.engine().endScope();
console.log(t2);
|
Output: Here, the scope is ended so the resultant tensor is being disposed.
An error occurred on line: 20
Tensor is disposed.
Reference: https://js.tensorflow.org/api/latest/#engine
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
13 Jun, 2022
Like Article
Save Article