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

Function decodeWeightMatrix

assets/main.js:746–760  ·  view source on GitHub ↗
(encoded, shape)

Source from the content-addressed store, hash-verified

744}
745
746function decodeWeightMatrix(encoded, shape) {
747 const rows = Math.max(0, Number(shape?.[0]) || 0);
748 const cols = Math.max(0, Number(shape?.[1]) || 0);
749 if (rows === 0 || cols === 0) {
750 return [];
751 }
752 const flat = decodeFloat16Base64(encoded, rows * cols);
753 const result = [];
754 for (let row = 0; row < rows; row += 1) {
755 const start = row * cols;
756 const end = start + cols;
757 result.push(flat.slice(start, end));
758 }
759 return result;
760}
761
762function normaliseShape(shape, fallback = []) {
763 const source = Array.isArray(shape) ? shape : fallback;

Callers 1

decodeSnapshotLayersFunction · 0.85

Calls 1

decodeFloat16Base64Function · 0.85

Tested by

no test coverage detected