Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

reduced dimension in hidden & input layer of FCN by 1. #62

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion FCNN.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,23 @@ function FCNN() {
var largest_layer_width = 0;
var nnDirection = 'right';
var showBias = false;
var wasBiasShown = false;
var showLabels = true;
var showArrowheads = false;
var arrowheadStyle = "empty";
var bezierCurves = false;

let sup_map = {'0': '⁰', '1': '¹', '2': '²', '3': '³', '4': '⁴', '5': '⁵', '6': '⁶', '7': '⁷', '8': '⁸', '9': '⁹'};
let sup = (s) => Array.prototype.map.call(s, (d) => (d in sup_map && sup_map[d]) || d).join('');

let textFn = (layer_index, layer_width) => {
let adjusted_width = layer_width;
if (showBias && layer_index !== architecture.length-1) {
adjusted_width -= 1;
}
return ((layer_index === 0 ? "Input" : (layer_index === architecture.length-1 ? "Output" : "Hidden")) + " Layer ∈ ℝ" + sup(adjusted_width.toString()));
};

let textFn = (layer_index, layer_width) => ((layer_index === 0 ? "Input" : (layer_index === architecture.length-1 ? "Output" : "Hidden")) + " Layer ∈ ℝ" + sup(layer_width.toString()));
var nominal_text_size = 12;
var textWidth = 70;

Expand Down Expand Up @@ -83,6 +91,14 @@ function FCNN() {
showBias = showBias_;
showLabels = showLabels_;
bezierCurves = bezierCurves_;
if (showBias) {
architecture = architecture.map((layer_width, layer_index) => layer_index !== architecture.length-1 ? layer_width + 1 : layer_width);
wasBiasShown = true;
}
else if (!showBias && wasBiasShown) {
architecture = architecture.map((layer_width, layer_index) => layer_index !== architecture.length-1 ? layer_width - 1 : layer_width);
wasBiasShown = false;
}

graph.nodes = architecture.map((layer_width, layer_index) => range(layer_width).map(node_index => {return {'id':layer_index+'_'+node_index,'layer':layer_index,'node_index':node_index}}));
graph.links = pairWise(graph.nodes).map((nodes) => nodes[0].map(left => nodes[1].map(right => {return right.node_index >= 0 ? {'id':left.id+'-'+right.id, 'source':left.id,'target':right.id,'weight':randomWeight()} : null })));
Expand Down