MCPcopy
hub / github.com/tensorflow/playground / shuffle

Function shuffle

src/dataset.ts:36–51  ·  view source on GitHub ↗
(array: any[])

Source from the content-addressed store, hash-verified

34 * library as the random generator.
35 */
36export function shuffle(array: any[]): void {
37 let counter = array.length;
38 let temp = 0;
39 let index = 0;
40 // While there are elements in the array
41 while (counter > 0) {
42 // Pick a random index
43 index = Math.floor(Math.random() * counter);
44 // Decrease counter by 1
45 counter--;
46 // And swap the last element with it
47 temp = array[counter];
48 array[counter] = array[index];
49 array[index] = temp;
50 }
51}
52
53export type DataGenerator = (numSamples: number, noise: number) => Example2D[];
54

Callers 1

generateDataFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…