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

Function loadLabels

mnist-acgan/data.js:103–124  ·  view source on GitHub ↗
(filename)

Source from the content-addressed store, hash-verified

101}
102
103async function loadLabels(filename) {
104 const buffer = await fetchOnceAndSaveToDiskWithBuffer(filename);
105
106 const headerBytes = LABEL_HEADER_BYTES;
107 const recordBytes = LABEL_RECORD_BYTE;
108
109 const headerValues = loadHeaderValues(buffer, headerBytes);
110 assert.equal(headerValues[0], LABEL_HEADER_MAGIC_NUM);
111
112 const labels = [];
113 let index = headerBytes;
114 while (index < buffer.byteLength) {
115 const array = new Int32Array(recordBytes);
116 for (let i = 0; i < recordBytes; i++) {
117 array[i] = buffer.readUInt8(index++);
118 }
119 labels.push(array);
120 }
121
122 assert.equal(labels.length, headerValues[1]);
123 return labels;
124}
125
126/** Helper class to handle loading training and test data. */
127class MnistDataset {

Callers 1

loadDataMethod · 0.70

Calls 2

loadHeaderValuesFunction · 0.70

Tested by

no test coverage detected