Tensorflow.js is an open-source library developed by Google for running machine learning models and deep learning neural networks in the browser or node environment. It also helps the developers to develop ML models in JavaScript language and can use ML directly in the browser or in Node.js.
The tf.getBackend() function is used to return the current backend name.
Syntax:
tf.getBackend()
Parameters:
Return Value: It returns a string value.
Example 1:
Javascript
tf.setBackend( "cpu" )
console.log(tf.getBackend())
|
Output:
cpu
Example 2: In this example, we have set the backend to the string “cpu” and then removed it and then set it to string “webgl”.
Javascript
tf.setBackend( "cpu" )
tf.removeBackend( 'cpu' )
console.log(tf.getBackend())
tf.setBackend( "webgl" )
console.log(tf.getBackend())
|
Output:
null
webgl
Reference: https://js.tensorflow.org/api/latest/#getBackend