Tensorflow.js tf.LayersModel 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 test method.
- 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.
evaluate(x, y, args?)
- 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 inputs. 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”.
Output: Here, randomNormal() method is used as tensor input.
Example 2: Using optimizer as “adam”, loss as “meanSquaredError” and “accuracy” as metrics.
Output: Here, truncatedNormal() method is used as tensor input and step parameter is also included.