MCPcopy Create free account
hub / github.com/DFin/Neural-Network-Visualisation / normaliseSlice

Function normaliseSlice

assets/main.js:95–107  ·  view source on GitHub ↗
(index)

Source from the content-addressed store, hash-verified

93
94 const pixelCache = new Map();
95 const normaliseSlice = (index) => {
96 if (pixelCache.has(index)) {
97 return pixelCache.get(index);
98 }
99 const start = index * sampleSize;
100 const slice = imageBytes.subarray(start, start + sampleSize);
101 const normalized = new Float32Array(sampleSize);
102 for (let i = 0; i < sampleSize; i += 1) {
103 normalized[i] = slice[i] / 255;
104 }
105 pixelCache.set(index, normalized);
106 return normalized;
107 };
108
109 return {
110 rows,

Callers 1

getSampleByIndexFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected