Tensorflow.js tf.util.assert() Function
Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.
The .util.assert() function is used to assert that the stated expression in the function as a parameter is true. And if it not true then an error is thrown along with the message stated in the method.
Parameters: This function accepts the following two parameters.
- expr: It is the expression which is to be asserted and it is of type Boolean.
- msg(() => string): It is a function that returns the stated message when the expression is not true and an error is thrown. Here, a function is utilized for performance reasons.
Return Value: It returns void.
Example 1: When the stated expression is true.
Successfully Executed, No Error Occurred Condition True
Example 2: When the stated expression is false and an error is thrown.
throw new Error(typeof msg === 'string' ? msg : msg()); Error: value of y is not 3.6
My Personal Notes arrow_drop_up
Please Login to comment...