Monday, November 18, 2024
Google search engine
HomeLanguagesJavascriptTensorflow.js tf.greaterEqual() Function

Tensorflow.js tf.greaterEqual() 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.greaterEqual() function is used to return the tensor of Boolean values for the two specified tensor values i.e. it returns true if the value of the first tensor is greater than or equal to the second tensor value else returns false. It supports broadcasting.

Syntax:  

tf.greaterEqual(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 values of the same data type as of tensor “a”.

Return Value: It returns the tensor of Boolean values i.e. true if the value of the first tensor is greater than or equal to the second tensor value else returns false.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Initializing two different tensors
const a = tf.tensor1d([2, 4, 6, 8]);
const b = tf.tensor1d([1, 4, 5, 9]);
  
// Calling the .greaterEqual() function
a.greaterEqual(b).print();


Output:

Tensor
   [true, true, true, false]

Example 2:

Javascript




// Importing the tensorflow library
import * as tf from "@tensorflow/tfjs"
  
// Calling the .greaterEqual() function with two
// Different tensors as its parameters
tf.tensor1d([1.5, 2.60, 2, 0.05, 4.5]).
greaterEqual(tf.tensor1d([1.25, 2.60, 2.0, .5, 4.05])).print();


Output:

Tensor
   [true, true, true, false, true]

Reference: https://js.tensorflow.org/api/latest/#greaterEqual

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!

Dominic Rubhabha-Wardslaus
Dominic Rubhabha-Wardslaushttp://wardslaus.com
infosec,malicious & dos attacks generator, boot rom exploit philanthropist , wild hacker , game developer,
RELATED ARTICLES

Most Popular

Recent Comments