Tensorflow.js tf.notEqual() 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.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
import * as tf from "@tensorflow/tfjs"
const a = tf.tensor1d([1, 2, 3, 4]);
const b = tf.tensor1d([1, 4, 3, 4]);
a.notEqual(b).print();
|
Output:
Tensor
[false, true, false, false]
Example 2:
Javascript
import * as tf from "@tensorflow/tfjs"
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
Last Updated :
12 May, 2021
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...