(layer, index)
| 766 | } |
| 767 | |
| 768 | function 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 | |
| 784 | function normaliseWeightsDescriptor(descriptor, baseUrl) { |
| 785 | if (!descriptor || typeof descriptor !== "object") return null; |
no test coverage detected