整理桌面
This commit is contained in:
20
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/events.js
generated
vendored
Normal file
20
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/events.js
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
$(document).on('click', '.panel div.clickable', function (e) {
|
||||
var $this = $(this); //Heading
|
||||
var $panel = $this.parent('.panel');
|
||||
var $panel_body = $panel.children('.panel-body');
|
||||
var $display = $panel_body.css('display');
|
||||
|
||||
if ($display == 'block') {
|
||||
$panel_body.slideUp();
|
||||
} else if($display == 'none') {
|
||||
$panel_body.slideDown();
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function(e){
|
||||
var $classy = '.panel.autocollapse';
|
||||
|
||||
var $found = $($classy);
|
||||
$found.find('.panel-body').hide();
|
||||
$found.removeClass($classy);
|
||||
});
|
89
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/graph.css
generated
vendored
Normal file
89
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/graph.css
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
.node {
|
||||
cursor: move;
|
||||
stroke-width: 1.5px;
|
||||
}
|
||||
.link {
|
||||
fill: none;
|
||||
stroke: #BDBDBD;
|
||||
stroke-width: 1.5px;
|
||||
opacity: 0.4;
|
||||
marker-end: url(#end-arrow);
|
||||
}
|
||||
.label {
|
||||
fill: #CCCCCC;
|
||||
font-size: 9px;
|
||||
text-anchor: middle;
|
||||
cursor: move;
|
||||
font-family: Arial;
|
||||
}
|
||||
#end-arrow{
|
||||
opacity: 0.4;
|
||||
}
|
||||
.INPUT{
|
||||
fill: #ff6666;
|
||||
stroke: #ff4d4d;
|
||||
}
|
||||
.OUTPUT{
|
||||
fill : #ff8c66;
|
||||
stroke: #ff794d;
|
||||
}
|
||||
.LOGISTIC{
|
||||
fill: #ffb366;
|
||||
stroke: #ffa64d;
|
||||
}
|
||||
.TANH{
|
||||
fill: #ffd966;
|
||||
stroke: #ffd24d;
|
||||
}
|
||||
.IDENTITY{
|
||||
fill: #ffff66;
|
||||
stroke: #ffff4d;
|
||||
}
|
||||
.STEP{
|
||||
fill: #d9ff66;
|
||||
stroke: #d2ff4d;
|
||||
}
|
||||
.RELU{
|
||||
fill: #b3ff66;
|
||||
stroke: #a6ff4d;
|
||||
}
|
||||
.SOFTSIGN{
|
||||
fill: #8cff66;
|
||||
stroke: #79ff4d;
|
||||
}
|
||||
.SINUSOID{
|
||||
fill: #66ff66;
|
||||
stroke: #4dff4d;
|
||||
}
|
||||
.GAUSSIAN{
|
||||
fill: #66ff8c;
|
||||
stroke: #4dff79;
|
||||
}
|
||||
.BENT_IDENTITY{
|
||||
fill: #66ffd9;
|
||||
stroke: #4dffd2;
|
||||
}
|
||||
.BIPOLAR{
|
||||
fill: #66d9ff;
|
||||
stroke: #4dd2ff;
|
||||
}
|
||||
.BIPOLAR_SIGMOID{
|
||||
fill: #66b3ff;
|
||||
stroke: #4da6ff;
|
||||
}
|
||||
.HARD_TANH{
|
||||
fill: #668cff;
|
||||
stroke: #4d79ff;
|
||||
}
|
||||
.ABSOLUTE{
|
||||
fill: #6666ff;
|
||||
stroke: #4d4dff;
|
||||
}
|
||||
.GATE{
|
||||
fill: #003300;
|
||||
stroke: #001a00;
|
||||
}
|
||||
.CONSTANT{
|
||||
fill: #ff00ff;
|
||||
stroke: #e600e6;
|
||||
}
|
122
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/graph.js
generated
vendored
Normal file
122
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/graph.js
generated
vendored
Normal file
@@ -0,0 +1,122 @@
|
||||
var NODE_RADIUS = 7;
|
||||
var REPEL_FORCE = 0;
|
||||
var LINK_DISTANCE = 100;
|
||||
|
||||
var drawGraph = function(graph, panel, width, height) {
|
||||
var d3cola = cola.d3adaptor()
|
||||
.avoidOverlaps(true)
|
||||
.size([width, height]);
|
||||
|
||||
var svg = d3.select(panel);
|
||||
|
||||
d3.selectAll(panel + "> *").remove();
|
||||
|
||||
// define arrow markers for graph links
|
||||
svg.append('svg:defs').append('svg:marker')
|
||||
.attr('id', 'end-arrow')
|
||||
.attr('viewBox', '0 -5 10 10')
|
||||
.attr('refX', 6)
|
||||
.attr('markerWidth', 4)
|
||||
.attr('markerHeight', 4)
|
||||
.attr('orient', 'auto')
|
||||
.append('svg:path')
|
||||
.attr('d', 'M0,-5L10,0L0,5')
|
||||
|
||||
graph.nodes.forEach(function (v) { v.height = v.width = 2 * NODE_RADIUS; });
|
||||
|
||||
d3cola
|
||||
.nodes(graph.nodes)
|
||||
.links(graph.links)
|
||||
//.constraints(graph.constraints)
|
||||
.symmetricDiffLinkLengths(REPEL_FORCE)
|
||||
.linkDistance(LINK_DISTANCE)
|
||||
.start(10, 15, 20);
|
||||
|
||||
var path = svg.selectAll(".link")
|
||||
.data(graph.links)
|
||||
.enter().append('svg:path')
|
||||
.attr('class', 'link')
|
||||
|
||||
path.append("title")
|
||||
.text(function (d) {
|
||||
var text = "";
|
||||
text += "Weight: " + Math.round(d.weight*1000)/1000 + "\n";;
|
||||
text += "Source: " + d.source.id + "\n";;
|
||||
text += "Target: " + d.target.id;
|
||||
return text;
|
||||
});
|
||||
|
||||
var node = svg.selectAll(".node")
|
||||
.data(graph.nodes)
|
||||
.enter().append("circle")
|
||||
.attr("class", function(d){
|
||||
return "node " + d.name;
|
||||
})
|
||||
.attr("r", function(d) { return NODE_RADIUS; })
|
||||
|
||||
.call(d3cola.drag);
|
||||
|
||||
node.append("title")
|
||||
.text(function (d){
|
||||
var text = "";
|
||||
text += "Activation: " + Math.round(d.activation*1000)/1000 + "\n";
|
||||
text += "Bias: " + Math.round(d.bias*1000)/1000 + "\n";
|
||||
text += "Position: " + d.id;
|
||||
return text;
|
||||
});
|
||||
|
||||
var label = svg.selectAll(".label")
|
||||
.data(graph.nodes)
|
||||
.enter().append("text")
|
||||
.attr("class", "label")
|
||||
.text(function (d){return '(' + d.index + ') ' + d.name; })
|
||||
.call(d3cola.drag)
|
||||
|
||||
d3cola.on("tick", function () {
|
||||
// draw directed edges with proper padding from node centers
|
||||
path.attr('d', function (d) {
|
||||
var deltaX = d.target.x - d.source.x,
|
||||
deltaY = d.target.y - d.source.y,
|
||||
dist = Math.sqrt(deltaX * deltaX + deltaY * deltaY),
|
||||
normX = deltaX / dist,
|
||||
normY = deltaY / dist;
|
||||
|
||||
if(isNaN(normX)) normX = 0;
|
||||
if(isNaN(normY)) normY = 0;
|
||||
|
||||
sourcePadding = NODE_RADIUS,
|
||||
targetPadding = NODE_RADIUS + 2,
|
||||
sourceX = d.source.x + (sourcePadding * normX),
|
||||
sourceY = d.source.y + (sourcePadding * normY),
|
||||
targetX = d.target.x - (targetPadding * normX),
|
||||
targetY = d.target.y - (targetPadding * normY);
|
||||
|
||||
// Defaults for normal edge.
|
||||
drx = 0,
|
||||
dry = 0,
|
||||
xRotation = 0, // degrees
|
||||
largeArc = 0, // 1 or 0
|
||||
sweep = 1; // 1 or 0
|
||||
|
||||
// Self edge.
|
||||
if (d.source.x === d.target.x && d.source.y === d.target.y) {
|
||||
drx = dist;
|
||||
dry = dist;
|
||||
xRotation = -45;
|
||||
largeArc = 1;
|
||||
drx = 20;
|
||||
dry = 20;
|
||||
targetX = targetX + 1;
|
||||
targetY = targetY + 1;
|
||||
}
|
||||
return 'M' + sourceX + ',' + sourceY + "A" + drx + "," + dry + " " + xRotation + "," + largeArc + "," + sweep + " " + targetX + ',' + targetY;
|
||||
});
|
||||
|
||||
node.attr("cx", function (d) { return d.x; })
|
||||
.attr("cy", function (d) { return d.y; })
|
||||
|
||||
label
|
||||
.attr("x", function (d) { return d.x + 10; })
|
||||
.attr("y", function (d) { return d.y - 10; });
|
||||
});
|
||||
};
|
38
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/import.js
generated
vendored
Normal file
38
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/import.js
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
var scripts = [
|
||||
{ type: 'script', url: "https://wagenaartje.github.io/neataptic/cdn/1.2.22/neataptic.js"},
|
||||
{ type: 'script', url: "https://cdnjs.cloudflare.com/ajax/libs/d3/3.0.0/d3.js"},
|
||||
{ type: 'script', url: "../../js/articles/neuroevolution/webcola.js"},
|
||||
{ type: 'script', url: "../../js/articles/neuroevolution/events.js"},
|
||||
{ type: 'script', url: "../../js/articles/neuroevolution/graph.js"},
|
||||
{ type: 'script', url: "../../js/articles/neuroevolution/neural.js"},
|
||||
{ type: 'css', url: "../../js/articles/neuroevolution/graph.css"}
|
||||
];
|
||||
|
||||
/** https://stackoverflow.com/questions/33330636/load-javascript-dynamically-and-sequentially **/
|
||||
function require(list) {
|
||||
function loadScript(link) {
|
||||
return new Promise(function(fulfill, reject) {
|
||||
if(link.type == 'script'){
|
||||
var script = document.createElement("script");
|
||||
script.addEventListener("load", fulfill);
|
||||
script.src = link.url;
|
||||
document.head.appendChild(script);
|
||||
} else if(link.type == 'css'){
|
||||
var stylesheet = document.createElement('link');
|
||||
stylesheet.addEventListener("load", fulfill);
|
||||
stylesheet.rel = 'stylesheet';
|
||||
stylesheet.type = 'text/css';
|
||||
stylesheet.href = link.url;
|
||||
stylesheet.media = "screen,print";
|
||||
document.head.appendChild(stylesheet);
|
||||
}
|
||||
});
|
||||
}
|
||||
loadScript(list.shift()).then(function() {
|
||||
if (list.length > 0) {
|
||||
require(list);
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
require(scripts);
|
165
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/neural.js
generated
vendored
Normal file
165
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/neural.js
generated
vendored
Normal file
@@ -0,0 +1,165 @@
|
||||
var Network = neataptic.Network;
|
||||
var Methods = neataptic.Methods;
|
||||
var Neat = neataptic.Neat;
|
||||
var Config = neataptic.Config;
|
||||
|
||||
Config.warnings = false;
|
||||
|
||||
var examples = [
|
||||
{
|
||||
set: [
|
||||
{ input: [0.0], output: [0.2] },
|
||||
{ input: [0.2], output: [0.4] },
|
||||
{ input: [0.4], output: [0.6] },
|
||||
{ input: [0.6], output: [0.8] },
|
||||
{ input: [0.8], output: [1.0] },
|
||||
{ input: [1.0], output: [0.8] },
|
||||
{ input: [0.8], output: [0.6] },
|
||||
{ input: [0.6], output: [0.4] },
|
||||
{ input: [0.4], output: [0.2] },
|
||||
{ input: [0.2], output: [0.0] }
|
||||
],
|
||||
options: {
|
||||
mutation: Methods.Mutation.ALL,
|
||||
equal: true,
|
||||
elitism: 5,
|
||||
iterations: 1500,
|
||||
clear: true,
|
||||
error: 0.003
|
||||
}
|
||||
},
|
||||
{
|
||||
set: [
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [0] },
|
||||
{ input: [0], output: [1] }
|
||||
],
|
||||
options: {
|
||||
mutation: Methods.Mutation.ALL,
|
||||
equal: true,
|
||||
elitism: 5,
|
||||
iterations: 1500,
|
||||
clear: true,
|
||||
error: 0.003
|
||||
}
|
||||
},
|
||||
{
|
||||
set: [
|
||||
{ input: [1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [1] }, // A
|
||||
{ input: [0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // B
|
||||
{ input: [0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // C
|
||||
{ input: [0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // D
|
||||
{ input: [0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [1] }, // E
|
||||
{ input: [0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // F
|
||||
{ input: [0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // G
|
||||
{ input: [0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // H
|
||||
{ input: [0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [1] }, // I
|
||||
{ input: [0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // J
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // K
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // L
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // M
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0], output: [0] }, // N
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0], output: [1] }, // O
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0], output: [0] }, // P
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0], output: [0] }, // Q
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0], output: [0] }, // R
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0], output: [0] }, // S
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0], output: [0] }, // T
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0], output: [1] }, // U
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0], output: [0] }, // V
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0], output: [0] }, // W
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0], output: [0] }, // X
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0], output: [0] }, // Y
|
||||
{ input: [0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1], output: [0] }, // Z
|
||||
],
|
||||
options: {
|
||||
mutation: Methods.Mutation.FFW,
|
||||
equal: true,
|
||||
elitism: 5,
|
||||
iterations: 1500,
|
||||
clear: true,
|
||||
error: 0.001
|
||||
}
|
||||
},
|
||||
]
|
||||
|
||||
function showModal(id, type){
|
||||
if(type == 0){
|
||||
var set = examples[id-1].set;
|
||||
var s = '';
|
||||
for(var i = 0; i < set.length; i++){
|
||||
var input = JSON.stringify(set[i].input);
|
||||
var output = JSON.stringify(set[i].output);
|
||||
s += (`Input: ${input}, output: ${output}\n`);
|
||||
}
|
||||
$('.modalcontent').html(s);
|
||||
$('.modal-title').text('Training set');
|
||||
} else if(type == 1){
|
||||
var options = examples[id-1].options;
|
||||
var keys = Object.keys(options);
|
||||
var s = '';
|
||||
for(var i = 0; i < keys.length; i++){
|
||||
if(keys[i] == 'mutation'){
|
||||
var value = '';
|
||||
for(var j = 0; j < options[keys[i]].length; j++){
|
||||
value += options[keys[i]][j].name + ', ';
|
||||
}
|
||||
} else {
|
||||
var value = options[keys[i]];
|
||||
}
|
||||
s += (`${keys[i]}: ${value}\n`);
|
||||
}
|
||||
$('.modalcontent').html(s);
|
||||
$('.modal-title').text('Evolve settings');
|
||||
} else if(type == 2){
|
||||
$('.modalcontent').html(examples[id-1].output);
|
||||
$('.modal-title').text('Output');
|
||||
}
|
||||
$('#modal').modal();
|
||||
}
|
||||
|
||||
function run(id){
|
||||
var set = examples[id-1].set;
|
||||
var options = examples[id-1].options;
|
||||
|
||||
$('.status' + id).show();
|
||||
$('.status' + id).text('Running...');
|
||||
setTimeout(freeze, 10, id, set, options)
|
||||
}
|
||||
|
||||
function freeze(id, set, options){
|
||||
var network = new Network(set[0].input.length, set[0].output.length);
|
||||
var results = network.evolve(set, options);
|
||||
$('.example' + id).width('100%');
|
||||
$('.example' + id).height(400);
|
||||
$('.example' + id).show();
|
||||
|
||||
var width = $('.example' + id).width();
|
||||
drawGraph(network.graph(width, 400), '.example' + id, width, 400);
|
||||
|
||||
var s = '';
|
||||
for(var i = 0; i < set.length; i++){
|
||||
var input = JSON.stringify(set[i].input);
|
||||
var targetoutput = JSON.stringify(set[i].output);
|
||||
var output = network.activate(set[i].input);
|
||||
|
||||
for(var j = 0; j < output.length; j++){
|
||||
output[j] = Math.round(output[j] * 1000) / 1000;
|
||||
}
|
||||
|
||||
output = JSON.stringify(output);
|
||||
s += (`Input: ${input}, wanted output: ${targetoutput}, actual: ${output}\n`);
|
||||
}
|
||||
examples[id-1].output = s;
|
||||
|
||||
$('.status' + id).text('Show outputs');
|
||||
$('.error' + id).text('Error ' + Math.round(-results.error * 1000) / 1000);
|
||||
$('.error' + id).show();
|
||||
}
|
3
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/webcola.js
generated
vendored
Normal file
3
node_modules/neataptic/mkdocs/theme/js/articles/neuroevolution/webcola.js
generated
vendored
Normal file
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user