(model)
| 1517 | } |
| 1518 | |
| 1519 | update(model) { |
| 1520 | if (!model || !Array.isArray(model.layers) || model.layers.length === 0) { |
| 1521 | this.emptyElement.style.display = "block"; |
| 1522 | this.summaryElement.style.display = "none"; |
| 1523 | this.layersElement.style.display = "none"; |
| 1524 | return; |
| 1525 | } |
| 1526 | |
| 1527 | const architecture = Array.isArray(model.architecture) ? model.architecture : []; |
| 1528 | const layerSummaries = model.layers.map((layer, index) => { |
| 1529 | const archInput = architecture[index]; |
| 1530 | const archOutput = architecture[index + 1]; |
| 1531 | const weightRows = Array.isArray(layer.weights) ? layer.weights : []; |
| 1532 | const inputSize = |
| 1533 | typeof archInput === "number" && Number.isFinite(archInput) |
| 1534 | ? archInput |
| 1535 | : weightRows[0]?.length ?? 0; |
| 1536 | const outputSizeCandidate = |
| 1537 | typeof archOutput === "number" && Number.isFinite(archOutput) |
| 1538 | ? archOutput |
| 1539 | : layer.biases?.length ?? 0; |
| 1540 | const outputSize = Number.isFinite(outputSizeCandidate) ? outputSizeCandidate : 0; |
| 1541 | |
| 1542 | let weightCount = 0; |
| 1543 | for (const row of weightRows) { |
| 1544 | if (row && typeof row.length === "number") { |
| 1545 | weightCount += row.length; |
| 1546 | } |
| 1547 | } |
| 1548 | |
| 1549 | const biasArray = layer.biases; |
| 1550 | const biasCount = typeof biasArray?.length === "number" ? biasArray.length : 0; |
| 1551 | const parameterCount = weightCount + biasCount; |
| 1552 | return { |
| 1553 | index, |
| 1554 | name: this.describeLayerName(layer.name, index), |
| 1555 | activation: typeof layer.activation === "string" ? layer.activation : null, |
| 1556 | inputSize, |
| 1557 | outputSize, |
| 1558 | weightCount, |
| 1559 | biasCount, |
| 1560 | parameterCount, |
| 1561 | }; |
| 1562 | }); |
| 1563 | |
| 1564 | const totalParameters = layerSummaries.reduce((sum, entry) => sum + entry.parameterCount, 0); |
| 1565 | this.summaryElement.innerHTML = ""; |
| 1566 | this.summaryElement.appendChild(this.buildSummaryLine("Gesamtparameter", totalParameters)); |
| 1567 | if (architecture.length > 0) { |
| 1568 | const firstArchitectureValue = architecture[0]; |
| 1569 | const lastArchitectureValue = architecture[architecture.length - 1]; |
| 1570 | const inputNodes = |
| 1571 | typeof firstArchitectureValue === "number" && Number.isFinite(firstArchitectureValue) |
| 1572 | ? firstArchitectureValue |
| 1573 | : layerSummaries[0]?.inputSize ?? 0; |
| 1574 | const lastLayer = layerSummaries[layerSummaries.length - 1]; |
| 1575 | const outputNodes = |
| 1576 | typeof lastArchitectureValue === "number" && Number.isFinite(lastArchitectureValue) |
nothing calls this directly
no test coverage detected