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
import * as tf from "@tensorflow/tfjs"
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
import * as tf from "@tensorflow/tfjs"
var num = (5*2*1)
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,
GeeksforGeeks 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!
Last Updated :
12 May, 2021
Like Article
Save Article