Tensorflow.js tf.GraphModel class .dispose() Method Last Updated : 10 Jun, 2022 Comments Improve Suggest changes Like Article Like Report 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 .dispose() function is used to free the memory that is being utilized by the weight tensors as well as resourceManager. Syntax: dispose() Parameters: This method do not holds any parameter. Return Value: It returns void. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining tensor input elements const model_Url = 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json'; // Calling the loadGraphModel() method const mymodel = await tf.loadGraphModel(model_Url); // Calling dispose() method mymodel.dispose(); // Printing output console.log('Model Disposed.'); Output: Model Disposed. Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining tensor input elements const model_Url = 'https://storage.googleapis.com/tfjs-models/savedmodel/mobilenet_v2_1.0_224/model.json'; // Calling the loadGraphModel() method const mymodel = await tf.loadGraphModel(model_Url); // Defining inputs const inputs = tf.zeros([1, 224, 224, 3]); // Calling dispose() method mymodel.dispose(); // Calling execute() method and // Printing output mymodel.execute(inputs).print(); Output: An error occurred Cannot read property 'backend' of undefined Here, an error occurred and the output is not printed as the stated model is already disposed. So, the execute() method is not able to return any output. Reference: https://js.tensorflow.org/api/latest/#tf.GraphModel.dispose Comment More infoAdvertise with us Next Article Tensorflow.js tf.GraphModel class .predict() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.GraphModel class .execute() Method 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 .execute() method is used to implement implication in favor of the given model for the stated input tensors. Syntax 2 min read Tensorflow.js tf.GraphModel class .save() Method 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 .save() function is used to save the structure and/or the weights of the stated GraphModel. Note: An 2 min read Tensorflow.js tf.GraphModel class .executeAsync() Method 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 .executeAsync() function is used to implement implication in favor of the given model for the stated input tensors 2 min read Tensorflow.js tf.GraphModel class .predict() Method 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 .predict() function is used to implement the implication in favor of input tensors. Syntax: predict(inputs, config? 2 min read Tensorflow.js tf.GraphModel Class Introduction: 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. Tensorflow.js tf.GraphModel class is used to build an acyclic graph from SavedModel and made it inference execution. tf. 2 min read Tensorflow.js tf.Tensor class .dispose() Method 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 .dispose() function is used to dispose the stated tf.Tensor from the memory. Syntax: dispose()Parameters: This meth 1 min read Like