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

Tensorflow.js tf.util.createShuffledIndices() Function

Tensorflow.js is an open-source library that is being developed by Google for running machine learning models as well as deep learning neural networks in the browser or node environment.

The .util.createShuffledIndices() function is used to create a new array that has randomized indices according to the stated quantity.

Syntax: This function accepts the following parameter.

tf.util.createShuffledIndices(n)

Parameters:  

  • n: It is the number according to which the indexes are printed randomly.

Return Value: It returns Uint32Array.

Example 1:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Calling util.createShuffledIndices() method
// and printing output
const randm_indxes = tf.util.createShuffledIndices(11);
console.log(randm_indxes);


Output:

Uint32Array(11) [
  9, 5, 4, 6,  7,
  8, 0, 1, 2, 10,
  3
]

Example 2:

Javascript




// Importing the tensorflow.js library
import * as tf from "@tensorflow/tfjs"
  
// Defining n
var num = (5*2*1)
  
// Calling util.createShuffledIndices() method
// and printing output
console.log(tf.util.createShuffledIndices(num));


Output:

Uint32Array(10) [
  5, 1, 9, 2, 0, 
  4, 8, 7, 6, 3  
]

Reference: https://js.tensorflow.org/api/latest/#util.createShuffledIndices

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

Most Popular

Recent Comments