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.notEqual() function is used to return a tensor of Boolean values i.e. true if the values of first tensor is not equal to the second one else returns false. It supports broadcasting.
Syntax:
tf.notEqual(a, b)
Parameters: This function accepts two parameters which are illustrated below:
- a: The first input tensor.
- b: The second input tensor. It should have same data type as “a”.
Return Value: It returns a tensor of Boolean values i.e. true if the values of first tensor is not equal to the second one else returns false.
Example 1:
Javascript
// Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Initializing some tensors const a = tf.tensor1d([1, 2, 3, 4]); const b = tf.tensor1d([1, 4, 3, 4]); // Calling the .notEqual() function a.notEqual(b).print(); |
Output:
Tensor [false, true, false, false]
Example 2:
Javascript
// Importing the tensorflow.js library import * as tf from "@tensorflow/tfjs" // Using tensors of some values as // the parameters of .notEqual() function tf.tensor1d([0.1, 2.06, 2.1, 3.0]).notEqual( tf.tensor1d([.1, 2.6, 2.0, 3])).print(); |
Output:
Tensor [false, true, true, false]
Reference: https://js.tensorflow.org/api/latest/#notEqual