MCPcopy
hub / github.com/tensorflow/playground / updateDecisionBoundary

Function updateDecisionBoundary

src/playground.ts:796–838  ·  view source on GitHub ↗

* Given a neural network, it asks the network for the output (prediction) * of every node in the network using inputs sampled on a square grid. * It returns a map where each key is the node ID and the value is a square * matrix of the outputs of the network for each input in the grid respectively

(network: nn.Node[][], firstTime: boolean)

Source from the content-addressed store, hash-verified

794 * matrix of the outputs of the network for each input in the grid respectively.
795 */
796function updateDecisionBoundary(network: nn.Node[][], firstTime: boolean) {
797 if (firstTime) {
798 boundary = {};
799 nn.forEachNode(network, true, node => {
800 boundary[node.id] = new Array(DENSITY);
801 });
802 // Go through all predefined inputs.
803 for (let nodeId in INPUTS) {
804 boundary[nodeId] = new Array(DENSITY);
805 }
806 }
807 let xScale = d3.scale.linear().domain([0, DENSITY - 1]).range(xDomain);
808 let yScale = d3.scale.linear().domain([DENSITY - 1, 0]).range(xDomain);
809
810 let i = 0, j = 0;
811 for (i = 0; i < DENSITY; i++) {
812 if (firstTime) {
813 nn.forEachNode(network, true, node => {
814 boundary[node.id][i] = new Array(DENSITY);
815 });
816 // Go through all predefined inputs.
817 for (let nodeId in INPUTS) {
818 boundary[nodeId][i] = new Array(DENSITY);
819 }
820 }
821 for (j = 0; j < DENSITY; j++) {
822 // 1 for points inside the circle, and 0 for points outside the circle.
823 let x = xScale(i);
824 let y = yScale(j);
825 let input = constructInput(x, y);
826 nn.forwardProp(network, input);
827 nn.forEachNode(network, true, node => {
828 boundary[node.id][i][j] = node.output;
829 });
830 if (firstTime) {
831 // Go through all predefined inputs.
832 for (let nodeId in INPUTS) {
833 boundary[nodeId][i][j] = INPUTS[nodeId].f(x, y);
834 }
835 }
836 }
837 }
838}
839
840function getLoss(network: nn.Node[][], dataPoints: Example2D[]): number {
841 let loss = 0;

Callers 2

drawNodeFunction · 0.85
updateUIFunction · 0.85

Calls 1

constructInputFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…