Tensorflow.js tf.LayersModel class .save() Method Last Updated : 01 Sep, 2021 Summarize Comments Improve Suggest changes Share 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 .save() function is used to save the structure and/or the weights of the stated LayersModel. Note: An IOHandler is an object which possesses a save method concerning the accurate signature specified.The save method controls the accumulation or else transmission of sequential data i.e. artifacts which describes the model's topology as well as weights upon or by means of a particular medium, like local storagefile, file downloads, IndexedDB in the web browser as well as HTTP requests to a server.TensorFlow.js enables IOHandler implementations in favor of a number of repeatedly utilized saving mediums, like tf.io.browserDownloads() and tf.io.browserLocalStorage.Moreover, this method also permits us to apply specific kinds of IOHandlers such as URL-like string techniques, like 'localstorage://' and 'indexeddb://'. Syntax: save(handlerOrURL, config?) Parameters: handlerOrURL: The stated instance of IOHandler or else a URL resembling, design-based string techniques in favor of IOHandler. It is of type io.IOHandler|string.config: The stated options in order to save the stated model. It is optional and is of type object. It has two arguments under it, as given below: trainableOnly: It states if only the trainable weights of the stated model is saved, overlooking the non-trainable weights. It is of type Boolean and defaults to false.includeOptimizer: It states if the stated optimizer will be stored or not. It is of type Boolean and defaults to false. Return Value: It returns the promise of io.SaveResult. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a model const model = tf.sequential( {layers: [tf.layers.dense({units: 2, inputShape: [2]})]}); // Calling save() method const res = await model.save('localstorage://mymodel'); // Printing output console.log(res) Output: { "modelArtifactsInfo": { "dateSaved": "2021-08-23T09:53:28.198Z", "modelTopologyType": "JSON", "modelTopologyBytes": 612, "weightSpecsBytes": 125, "weightDataBytes": 24 } } Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Creating a model const model = tf.sequential( {layers: [tf.layers.dense({units: 2, inputShape: [2]})]}); // Calling save() method const res = await model.save('localstorage://mymodel', true, true); // Printing output console.log(JSON.stringify(res)) Output: {"modelArtifactsInfo":{"dateSaved":"2021-08-23T09:55:33.044Z", "modelTopologyType":"JSON","modelTopologyBytes":612, "weightSpecsBytes":125,"weightDataBytes":24}} Reference: https://js.tensorflow.org/api/latest/#tf.LayersModel.save Comment More infoAdvertise with us Next Article Tensorflow.js tf.LayersModel class .fit() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.LayersModel class .summary() Method The tf.LayersModel is a class used for training, inference, and evaluation of layers model in tensorflow.js. It contains methods for training, evaluation, prediction, and for saving of layers model purposes. So in this post, we are going to know about the model.summary() function. The model.summary( 2 min read Tensorflow.js tf.LayersModel 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 produce the output estimates for the given input instances. Moreover, the calculatio 2 min read Tensorflow.js tf.LayersModel class .fit() Method 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. The tf.LayersModel class .fit( ) method is used to train the model for the fixed number of epochs (iterations on a dataset). Syntax: f 4 min read Tensorflow.js tf.LayersModel class .compile() Method 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. The .compile() function configures and makes the model for training and evaluation process. By calling .compile() function we prepare 4 min read Tensorflow.js tf.LayersModel Class 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.LayerModel class is used to training, interface and evaluation of model. It have many method for training, evaluatio 2 min read Tensorflow.js tf.LayersModel class .getLayer() 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 .getLayer() function is used to fetch a layer that is based upon either its name (which must be unique) or else an 2 min read Like