From f04d9f1773b6a0e109867bc6a5546a716565b1a7 Mon Sep 17 00:00:00 2001 From: schneefux Date: Sat, 9 Apr 2016 17:27:37 +0200 Subject: training --- code/errorvis.js | 3 ++- code/weightvis.js | 11 +++++++---- code/weightviswrapper.js | 13 +++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) (limited to 'code') diff --git a/code/errorvis.js b/code/errorvis.js index 9cd87f4..03c5eba 100644 --- a/code/errorvis.js +++ b/code/errorvis.js @@ -16,7 +16,7 @@ var ErrorVis = (function() { this.svgContainer .style("margin-top", "1.5em") .style("margin-bottom", "1em") - .style("height", "100%") + .style("height", "75%") // TODO find optimal height .style("width", "100%"); this.spinner = this.container.append("div") @@ -82,6 +82,7 @@ var ErrorVis = (function() { .domain(d3.extent(this.data)); var xAxis = d3.svg.axis() + .tickFormat("") .scale(this.scalerX); var yAxis = d3.svg.axis() .orient("left") diff --git a/code/weightvis.js b/code/weightvis.js index 6e9fc1d..428d3ce 100644 --- a/code/weightvis.js +++ b/code/weightvis.js @@ -510,8 +510,8 @@ var NetVisualizer = (function() { this.reposition(); }; - NetVisualizer.prototype.visualActivate = function(inputs) { - var activations = this.activate(inputs); + NetVisualizer.prototype.visualActivate = function(inputs, step) { + var activations = this.activate(inputs, step); var flatActivations = [].concat.apply([], activations); var max = d3.max(flatActivations, Math.abs), min = d3.min(flatActivations, Math.abs); @@ -521,10 +521,13 @@ var NetVisualizer = (function() { .style("fill", fNodeColor); }; - NetVisualizer.prototype.activate = function(inputs) { + NetVisualizer.prototype.activate = function(inputs, step) { // assumes the sigmoid function is used as activation function activation(x) { return 1 / (1 + Math.exp(-x)); } - var weights = this.data[this.layout.data.batches-1][this.layout.data.epochs-1]; + if (typeof(step) == "undefined") step = this.getSteps() - 1; + var batch = Math.floor(step / this.layout.data.epochs), + epoch = step % this.layout.data.epochs; + var weights = this.data[batch][epoch]; var lastLayerOut = inputs; var activations = [inputs]; var hasBias = false; diff --git a/code/weightviswrapper.js b/code/weightviswrapper.js index ca31916..52b60ed 100644 --- a/code/weightviswrapper.js +++ b/code/weightviswrapper.js @@ -17,7 +17,7 @@ var WeightVisWrapper = (function() { this.svgContainer .style("margin-top", "1.5em") .style("margin-bottom", "1em") - .style("height", "85%") // TODO find optimal height + .style("height", "75%") // TODO find optimal height .style("width", "100%"); this.spinner = this.container.append("div") @@ -96,7 +96,7 @@ var WeightVisWrapper = (function() { } }); this.slider.attr("max", this.steps()-1); - this.slider.node().addEventListener("input", function() { self.jumpTo(self.value); }); + this.slider.node().addEventListener("input", function() { self.jumpTo(this.value); }); this.button.node().addEventListener("click", function toggle() { if (self.button.attr("data-pressed") != "true") { var step = self.slider.node().value; @@ -185,13 +185,13 @@ var WeightVisWrapper = (function() { return this.netVisualizer.getSteps(); }; - WeightVisWrapper.prototype.calculate = function(inputs) { + WeightVisWrapper.prototype.calculate = function(inputs, step) { // returns the final layer's outputs - return this.netVisualizer.activate(inputs).pop(); + return this.netVisualizer.activate(inputs, step).pop(); }; - WeightVisWrapper.prototype.activate = function(inputs) { - this.netVisualizer.visualActivate(inputs); + WeightVisWrapper.prototype.activate = function(inputs, step) { + this.netVisualizer.visualActivate(inputs, step); }; return WeightVisWrapper; @@ -200,6 +200,7 @@ var WeightVisWrapper = (function() { /* helps with impress.js' stepenter/stepleave events */ // TODO move into its own file // TODO must be a step's direct child +// TODO not steppable var VisIntegrater = (function() { function VisIntegrater(enterCb, leaveCb, selector) { var self = this; -- cgit v1.3.1