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

Function shuffle

boston-housing/data.js:110–126  ·  view source on GitHub ↗

* Shuffles data and target (maintaining alignment) using Fisher-Yates * algorithm.flab

(data, target)

Source from the content-addressed store, hash-verified

108 * algorithm.flab
109 */
110function shuffle(data, target) {
111 let counter = data.length;
112 let temp = 0;
113 let index = 0;
114 while (counter > 0) {
115 index = (Math.random() * counter) | 0;
116 counter--;
117 // data:
118 temp = data[counter];
119 data[counter] = data[index];
120 data[index] = temp;
121 // target:
122 temp = target[counter];
123 target[counter] = target[index];
124 target[index] = temp;
125 }
126};

Callers 1

loadDataMethod · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected