Tensorflow.js tf.constraints.Constraint 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. The tf.constraints.Constraint class is used to extend the serialization.Serializable class. Moreover, it is the base class in favor of the functions which enforce constraints on the weight values.This tf.constraints.Constraint class contains four inbuilt functions which are illustrated below:  Example 1: In this example, tf.constraints.Constraint class .constraints.minMaxNorm() function is used to create a minMaxNorm constraint based on the given config object. It is inherited from the constraint class. Constraints are the attributes of layers like weight, kernels, biases. minMaxNorm is a weight constraint.Javascriptimport * as tf from “@tensorflow/tfjs”  var a = tf.constraints.maxNorm(2, 0)  console.log(a)Output:{
“defaultMaxValue”: 2,
“defaultAxis”: 0,
“maxValue”: 2,
“axis”: 0
}Example 2: In this example, tf.constraints.Constraint class .constraints.nonNeg() function is used to create a nonNeg constraint. nonNeg is a non-negative weight constraint. It is inherited from constraint class. Constraints are the attributes of the layers.Javascriptimport * as tf from “@tensorflow/tfjs”  const constraint = tf.constraints.nonNeg( )  console.log(constraint)Output:{}Reference: https://js.tensorflow.org/api/latest/#class:constraints.Constraint