Skip to content
Related Articles

Related Articles

Tensorflow.js tf.getBackend() Function

View Discussion
Improve Article
Save Article
  • Last Updated : 18 May, 2021

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:

  • It takes no parameters

Return Value: It returns a string value.

Example 1:

Javascript




// Setting the backend
tf.setBackend("cpu")
  
// Getting the backend using getBackend method
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




// Setting the backend
tf.setBackend("cpu")
  
tf.removeBackend('cpu')
  
console.log(tf.getBackend())
  
tf.setBackend("webgl")
// Getting the backend using getBackend method
console.log(tf.getBackend())

Output:

null
webgl

Reference: https://js.tensorflow.org/api/latest/#getBackend

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!