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

Function normaliseLayerMetadata

assets/main.js:768–782  ·  view source on GitHub ↗
(layer, index)

Source from the content-addressed store, hash-verified

766}
767
768function normaliseLayerMetadata(layer, index) {
769 const layerIndex = Number.isFinite(layer?.layer_index) ? Number(layer.layer_index) : index;
770 const weightShape = normaliseShape(layer?.weight_shape);
771 const biasShape = normaliseShape(layer?.bias_shape);
772 const resolvedWeightShape =
773 weightShape.length === 2 ? weightShape : [biasShape[0] ?? 0, weightShape[1] ?? 0];
774 const resolvedBiasShape = biasShape.length >= 1 ? biasShape : [resolvedWeightShape[0] ?? 0];
775 return {
776 layerIndex,
777 name: typeof layer?.name === "string" ? layer.name : `dense_${layerIndex}`,
778 activation: typeof layer?.activation === "string" ? layer.activation : "relu",
779 weightShape: resolvedWeightShape,
780 biasShape: resolvedBiasShape,
781 };
782}
783
784function normaliseWeightsDescriptor(descriptor, baseUrl) {
785 if (!descriptor || typeof descriptor !== "object") return null;

Callers 1

hydrateTimelineFunction · 0.85

Calls 1

normaliseShapeFunction · 0.85

Tested by

no test coverage detected