Tensorflow.js tf.metrics.binaryAccuracy() Function
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.metrics.binaryAccuracy() function is used to calculate how often predictions match binary labels. And the function takes two tensors as a parameter and the value of tensors is between 0 and 1.
tf.metrics.binaryAccuracy (True, Prediction)
- True: It is the binary tensor of truth and the tensor can contain values between 0 and 1.
- Prediction: It is the tensor of predictions and the tensor can contain values between 0 and 1.
Return Value: It returns a tensor.
Example 1: In this example, we are giving two 1d tensors that contain values between 0 and 1 as a parameter, and the metrics.binaryAccuracy function will calculate the predictions match and return a tensor.
Example 2: In this example, we are giving two 2d tensors that contain values 0 and 1 as a parameter, and the metrics.binaryAccuracy function will calculate the predictions match and return a tensor.
Tensor [0.75, 0]