Tensorflow.js tf.LayersModel class .predict() Method Last Updated : 21 Jun, 2021 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 .predict() function is used to produce the output estimates for the given input instances. Moreover, the calculations here are made in sets. Where, the step operation is not supportive at present as core backend of tensorflow.js is only required. Syntax: predict(x, args?) Parameters: x: It is the stated input data, like a Tensor, otherwise an array of tf.Tensors in case the model has various inputs. It can be of type tf.Tensor, or tf.Tensor[].args: It is the stated ModelPredictArgs object that holds elective fields. batchSize: It is the stated batch dimension which is of type integer. In case its undefined, the by default value will be 32.verbose: It is the stated verbosity mode whose by default value is false. Return Value: It returns the tf.Tensor object or tf.Tensor[]. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining model const Mod = tf.sequential({ layers: [tf.layers.dense({units: 2, inputShape: [30]})] }); // Calling predict() method and // Printing output Mod.predict(tf.randomNormal([6, 30])).print(); Output: Tensor [[-0.7650393, -0.8317917], [-0.7274997, 1.827635 ], [-0.9398478, -0.2998275], [-1.0945926, -1.9154934], [0.0067322 , -1.9220339], [0.2052939 , 0.6488774 ]] Example 2: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Calling predict() method and // Printing output tf.sequential({ layers: [tf.layers.dense({units: 3, inputShape: [10]})] }).predict(tf.truncatedNormal([2, 10]), {batchSize: 2}, true).print(); Output: Tensor [[0.2670097, -1.2741219, -0.3159108], [0.9108799, -0.1305539, -0.1370454]] Reference: https://js.tensorflow.org/api/latest/#tf.LayersModel.predict Comment More infoAdvertise with us Next Article Tensorflow.js tf.LayersModel class .predict() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.LayersModel class .predictOnBatch() 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 .predictOnBatch() function is used to return expectancies for an individual group of instances. Syntax: Â predictOn 2 min read Tensorflow.js tf.LayersModel class .save() 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 .save() function is used to save the structure and/or the weights of the stated LayersModel. Note: An IOHandler is 2 min read 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 .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.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 Like