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

Function chunk

intent-classifier/training/util.js:45–60  ·  view source on GitHub ↗
(array, chunkSize)

Source from the content-addressed store, hash-verified

43}
44
45function chunk(array, chunkSize) {
46 const result = [];
47 let batch = [];
48 for (let index = 0; index < array.length; index++) {
49 const element = array[index];
50 batch.push(element);
51 if (batch.length === chunkSize) {
52 result.push(batch);
53 batch = [];
54 }
55 }
56 if (batch.length > 0) {
57 result.push(batch);
58 }
59 return result;
60}
61
62function unique(array) {
63 return Array.from(new Set(array));

Callers 2

embedTokensFunction · 0.85
csvToTensorsFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected