Introduction: 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 .ready() function is used to return a promise which determines at what time the recently picked backend or else the topmost priority one has been initialized. Moreover, we need to await this promise if we are utilizing a backend that possesses asynchronous initialization.
Syntax:
tf.ready()
Parameters: This method does not hold any parameter.
Return Value: It returns promise of void.
Example 1:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.setBackend( 'wasm' );
await tf.ready().then(() => {
console.log(tf.backend().blockSize)
});
|
Output:
48
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
tf.setBackend( 'webgl' );
await tf.ready().then(() => {
console.log(JSON.stringify(tf.getBackend()))
});
|
Output:
"webgl"
Reference: https://js.tensorflow.org/api/latest/#ready
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 :
22 Aug, 2021
Like Article
Save Article