(firstStep = false)
| 849 | } |
| 850 | |
| 851 | function updateUI(firstStep = false) { |
| 852 | // Update the links visually. |
| 853 | updateWeightsUI(network, d3.select("g.core")); |
| 854 | // Update the bias values visually. |
| 855 | updateBiasesUI(network); |
| 856 | // Get the decision boundary of the network. |
| 857 | updateDecisionBoundary(network, firstStep); |
| 858 | let selectedId = selectedNodeId != null ? |
| 859 | selectedNodeId : nn.getOutputNode(network).id; |
| 860 | heatMap.updateBackground(boundary[selectedId], state.discretize); |
| 861 | |
| 862 | // Update all decision boundaries. |
| 863 | d3.select("#network").selectAll("div.canvas") |
| 864 | .each(function(data: {heatmap: HeatMap, id: string}) { |
| 865 | data.heatmap.updateBackground(reduceMatrix(boundary[data.id], 10), |
| 866 | state.discretize); |
| 867 | }); |
| 868 | |
| 869 | function zeroPad(n: number): string { |
| 870 | let pad = "000000"; |
| 871 | return (pad + n).slice(-pad.length); |
| 872 | } |
| 873 | |
| 874 | function addCommas(s: string): string { |
| 875 | return s.replace(/\B(?=(\d{3})+(?!\d))/g, ","); |
| 876 | } |
| 877 | |
| 878 | function humanReadable(n: number): string { |
| 879 | return n.toFixed(3); |
| 880 | } |
| 881 | |
| 882 | // Update loss and iteration number. |
| 883 | d3.select("#loss-train").text(humanReadable(lossTrain)); |
| 884 | d3.select("#loss-test").text(humanReadable(lossTest)); |
| 885 | d3.select("#iter-number").text(addCommas(zeroPad(iter))); |
| 886 | lineChart.addDataPoint([lossTrain, lossTest]); |
| 887 | } |
| 888 | |
| 889 | function constructInputIds(): string[] { |
| 890 | let result: string[] = []; |
no test coverage detected
searching dependent graphs…