Tensorflow.js tf.Sequential class.predict() Method Last Updated : 04 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() method is used to produce the output expectations considering the stated input instances. Moreover, the calculation is performed here in groups. Syntax: predict(x, args?) Parameters: x: It is the stated input data, like a tensor, or else an array of tf.Tensors in case the model has numerous inputs. It can be type tf.Tensor, or tf.Tensor[].args: It is an optional parameter that is of type object. batchSize: It is the stated batch size in integer form and is optional parameter. Moreover, in case its not specified, then the default value is 32.verbose: It is the stated verbosity mode which is by default false. It is of type Boolean and is optional. Return Value: It returns tf.Tensor or tf.Tensor[]. Example 1: JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining model const modl = tf.sequential({ layers: [tf.layers.dense({units: 2, inputShape: [40]})] }); // Calling predict() method and // Printing output modl.predict(tf.truncatedNormal([7, 40])).print(); Output: Tensor [[0.1556173 , 1.2365075 ], [-1.7945877, 2.3424799 ], [0.3632407 , -0.1731701], [0.195157 , -0.7823027], [0.4565429 , 2.512109 ], [-1.2392806, 0.1868197 ], [0.6895663 , -0.2006246]] 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: [20]})] }).predict(tf.randomNormal([8, 20])).print(); Output: Tensor [[-1.1149288, 0.8968778 , -0.7492741], [1.3654473 , -0.471923 , 1.3632329 ], [0.5550661 , 0.6949158 , 1.9761562 ], [-0.2109454, -0.3558912, 0.243051 ], [-1.2827762, 0.5370077 , 0.1645843 ], [0.1542411 , -1.359634 , -0.1656512], [-0.4721956, 0.3904444 , 0.7398967 ], [-0.2076109, -3.0447464, 1.3338548 ]] Reference: https://js.tensorflow.org/api/latest/#tf.Sequential.predict Comment More infoAdvertise with us Next Article Tensorflow.js tf.Sequential class.predict() Method nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads Tensorflow.js tf.Sequential Class .add() 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 .add() function is used to affix a layer prototype on the topmost part of the layer stack. Syntax: add(layer) Param 2 min read Tensorflow.js tf.Sequential 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. Tensorflow.jstf.Sequential class .fit( ) method is used to train the model for the fixed number of epochs( iterations on a dataset ). 4 min read Tensorflow.js tf.Sequential class .summary() 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 .summary() function in tensorflow.js is used to print a text summary in favor of the sequential model's layers. Mor 2 min read Tensorflow.js tf.Sequential class .evaluate() 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 .evaluate() function is used to find the measure of loss and the values of metrics in favor of the prototype in tes 3 min read Tensorflow.js tf.Tensor class .print() 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.print() function is used to Prints information about the tf.Tensor including its data. Syntax: tf.print(value, verbose) Paramet 2 min read Tensorflow.js tf.Sequential 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.Sequential class is a model of the collection of layers in stack form. These layers are connected to the respective n 2 min read Tensorflow.js tf.Sequential class .fitDataset() 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. Tensorflow.js tf.Sequential class .fitDataset() method is used to trains the model using a dataset object. Syntax: model.fitDataset(da 4 min read Tensorflow.js tf.Sequential class .trainOnBatch() 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 .trainOnBatch() function is used to run a separate gradient update on a particular batch of data. Note: This method 2 min read Tensorflow.js tf.Sequential class .evaluateDataset() 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 .evaluateDataset() function is used to evaluate the stated sequential model by means of a stated dataset object. No 3 min read Like