Saturday, February 7, 2026
HomeLanguagesJavascriptTensorflow.js tf.notEqual() Function

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




// 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

Whether you’re preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, neveropen Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we’ve already empowered, and we’re here to do the same for you. Don’t miss out – check it out now!
RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32493 POSTS0 COMMENTS
Milvus
126 POSTS0 COMMENTS
Nango Kala
6864 POSTS0 COMMENTS
Nicole Veronica
11990 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12083 POSTS0 COMMENTS
Shaida Kate Naidoo
7000 POSTS0 COMMENTS
Ted Musemwa
7241 POSTS0 COMMENTS
Thapelo Manthata
6951 POSTS0 COMMENTS
Umr Jansen
6936 POSTS0 COMMENTS