Tensorflow.js tf.Sequential class .evaluate() Method Last Updated : 30 Jun, 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 .evaluate() function is used to find the measure of loss and the values of metrics in favor of the prototype in test method. Note: Here, the Loss value as well as metrics are determined at the time of compilation, that is required to take place before calling to evaluate() method.Here, the enumeration is made in groups. Syntax: evaluate(x, y, args?) Parameters: x: It is the stated tf.Tensor of test material, or else an array of tf.Tensors in case the prototype has various inputs. It can be of type tf.Tensor, or tf.Tensor[].y: It is the stated tf.Tensor of target material, or else an array of tf.Tensors in case the prototype has various outputs. It can be of type tf.Tensor, or tf.Tensor[].args: It is stated ModelEvaluateArgs, that holds elective fields. It is an object.batchSize: It is the stated batch size and in case is undefined, then the by default value is 32. It is of type number.verbose: It is the stated verbosity mode. It is of type ModelLoggingVerbosity.sampleWeight: It is the stated tensor of weights in order to weight the involvement of various instances to the loss as well as metrics. It is of type Tf.tensor.steps: It is the total number of steps i.e. groups of instances, prior to the declaration of estimation round being terminated. It is neglected with the by default value of unspecified. It is of type number. Return Value: It returns tf.Scalar or tf.Scalar[]. Example 1: Using optimizer as “sgd” and loss as “meanAbsoluteError”. JavaScript // Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Defining model const modl = tf.sequential({ layers: [tf.layers.dense({units: 3, inputShape: [40]})] }); // Compiling model modl.compile({optimizer: 'sgd', loss: 'meanAbsoluteError'}); // Calling evaluate() and randomNormal // method const output = modl.evaluate( tf.randomNormal([5, 40]), tf.randomNormal([5, 3]), {Sizeofbatch: 3} ); // Printing output output.print(); Output: Tensor 1.554270625114441 Here, randomNormal() method is used as tensor input. Example 2: Using optimizer as “adam”, loss as “meanSquaredError” and “accuracy” as metrics. 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: [30]})] }); // Compiling model modl.compile({optimizer: 'adam', loss: 'meanSquaredError'}, (metrics = ["accuracy"])); // Calling evaluate() and truncatedNormal // method const output = modl.evaluate( tf.truncatedNormal([6, 30]), tf.truncatedNormal([6, 2]), {Sizeofbatch: 2}, {steps: 2}); // Printing output output.print(); Output: Tensor 2.7340292930603027 Here, truncatedNormal() method is used as tensor input and step parameter is also included. Reference: https://js.tensorflow.org/api/latest/#tf.Sequential.evaluate Comment More infoAdvertise with us Next Article Tensorflow.js tf.Sequential class .fit() Method N nidhi1352singh Follow Improve Article Tags : JavaScript Web Technologies Tensorflow.js Similar Reads 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 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 .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 .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.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() method is used to produce the output expectations considering the stated input instances. Moreover, the 2 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 Like