MCPcopy Create free account
hub / github.com/tensorflow/tfjs-examples / shuffle

Function shuffle

website-phishing/utils.js:64–80  ·  view source on GitHub ↗
(data, label)

Source from the content-addressed store, hash-verified

62 * Shuffles data and label using Fisher-Yates algorithm.
63 */
64export async function shuffle(data, label) {
65 let counter = data.length;
66 let temp = 0;
67 let index = 0;
68 while (counter > 0) {
69 index = (Math.random() * counter) | 0;
70 counter--;
71 // data:
72 temp = data[counter];
73 data[counter] = data[index];
74 data[index] = temp;
75 // label:
76 temp = label[counter];
77 label[counter] = label[index];
78 label[index] = temp;
79 }
80};
81
82/**
83 * Calculate the arithmetic mean of a vector.

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected