()
| 470 | const min = Math.max(0, Number.parseFloat(connectionThresholdSlider.min) || 0); |
| 471 | const fallbackMaxAttr = Number.parseFloat(connectionThresholdSlider.getAttribute("max")); |
| 472 | const computeSceneMaxMagnitude = () => { |
| 473 | if (typeof neuralScene.getMaxConnectionWeightMagnitude === "function") { |
| 474 | const sceneValue = neuralScene.getMaxConnectionWeightMagnitude(); |
| 475 | if (Number.isFinite(sceneValue)) { |
| 476 | return sceneValue; |
| 477 | } |
| 478 | } |
| 479 | let maxMagnitude = 0; |
| 480 | if (Array.isArray(neuralScene.mlp?.layers)) { |
| 481 | for (const layer of neuralScene.mlp.layers) { |
| 482 | if (!Array.isArray(layer?.weights)) continue; |
| 483 | for (const row of layer.weights) { |
| 484 | if (!Array.isArray(row)) continue; |
| 485 | for (const weight of row) { |
| 486 | const magnitude = Math.abs(Number(weight)); |
| 487 | if (Number.isFinite(magnitude) && magnitude > maxMagnitude) { |
| 488 | maxMagnitude = magnitude; |
| 489 | } |
| 490 | } |
| 491 | } |
| 492 | } |
| 493 | } |
| 494 | return maxMagnitude; |
| 495 | }; |
| 496 | const updateThresholdSliderBounds = () => { |
| 497 | const sceneMax = computeSceneMaxMagnitude(); |
| 498 | const fallback = Number.isFinite(fallbackMaxAttr) ? fallbackMaxAttr : 0; |
no test coverage detected