-
-
Save PirosB3/6961492 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// GRID DEFININTION | |
dg 1,1, INPUT_NODE_TYPE | |
mg Input | |
mg Bias | |
dg 1,2, STANDARD_NODE_TYPE | |
mg Output | |
dg 1,1, LINEAR_NODE_TYPE | |
mg Classification | |
// WIRE DEFININTION | |
connect Bias, Output | |
connect Input, Output | |
connect Output, Classification | |
drawwires | |
// SET WEIGHTS AND OUTPUTS | |
set_node_output first_node(Bias), 1 | |
set_weightsbetgrids Input, Output, 0.5 | |
set_weightsbetgrids Output, Classification, 0.5 | |
set_weightsbetnodes first_node(Bias), nth_node(Output, 1), 0.5 | |
// GRAPH DEFININTION | |
graph_default_gridtype 0 | |
graph_default_axislabel "Input:", "Output" | |
graph_default_range 0, 0, 99, 1 | |
makegraph first_output_node | |
makegraph second_output_node | |
//make buttons | |
defpan progpan | |
button "return", "poppan" | |
butgap | |
button "Run", "gosub run" | |
pushpan progpan | |
// DRAW STATIC BIAS NODE | |
drawgrid Bias | |
end | |
run: | |
int z=0 | |
for z=0 to 100 | |
rand_node_output first_node(Input), 0, 1 | |
drawnode first_node(Input) | |
updategrid Output | |
updategrid Classification | |
drawgrid Output | |
drawgrid Classification | |
graph_active first_output_node | |
plot float(z), node_output(nth_node(Output, 0)), YELLOW | |
graph_active second_output_node | |
plot float(z), node_output(nth_node(Output, 1)), YELLOW | |
print node_output(first_node(Classification)) | |
ms_delay 200 | |
next z | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DEFINE A GRID | |
dg 4,1, [LINEAR_NODE_TYPE or STANDARD_NODE_TYPE] | |
mg Grid1 | |
CONNECT NODES WITHIN GRID[S] | |
connectnodes nth_node(Grid1, n), nth_node(Grid1, n) | |
- THROUGHOUT TWO GRIDS | |
connectnodes first_node(input), first_node(output) | |
[ALL NODES IN GRIDS] | |
connect input, output | |
SET WEIGHTS | |
- [THROUGHOUT ALL THE NET] set_weights 0.95 | |
- [ONE AT A TIME]: | |
let wire_ID = nth_output_wire(nth_node(input_grid,1), 1) | |
set_wire_weight wire_ID, 0.2 | |
OR | |
set_weightsbetnodes input_node,output_node,1.5 | |
LOAD DATA IN ARRAY | |
float inputs[4] | |
loadfloatarray inputs, "TEST1.DAT" | |
LOOP | |
int i = 0 | |
for i=0 to 3 | |
set_node_output nth_node(Grid1, i), inputs[i] | |
next i | |
UPDATE | |
updategrid Grid1 | |
drawgrid Grid1 | |
drawwires | |
DELAY | |
ms_delay 200 | |
GRAPH | |
graph_default_gridtype 0 | |
graph_default_axislabel "Input:", "Output" | |
graph_default_range 0, 0, 99, 1 | |
makegraph third_node_output | |
- To activate: | |
graph_active third_node_output | |
- To draw | |
plot float(i), node_output(nth_node(Grid1, 2)), YELLOW |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//abc | |
// build | |
dg 1,1, INPUT_NODE_TYPE | |
mg input | |
mg bias | |
dg 1,1,STANDARD_NODE_TYPE | |
mg output | |
// init | |
set_node_output first_node(bias), 1 | |
// connection | |
connect input, output | |
connect bias, output | |
connectnodes first_node(input), first_node(output) | |
connectnodes first_node(bias), first_node(output) | |
// weights | |
set_weightsbetnodes input, output, 2 | |
set_weightsbetnodes bias, output, 0 | |
// Draw | |
uw | |
//make buttons | |
defpan progpan | |
button "return", "poppan" | |
butgap | |
button "Run", "gosub run" | |
pushpan progpan | |
// graph | |
graph_default_gridtype 0 | |
graph_default_axislabel "Input:", "Output" | |
graph_default_range -1, 0, 1, 1 | |
makegraph test | |
run: | |
float xin[29] | |
graph_active test | |
int i | |
for i = 0 to 28 | |
xin[i] = -99 | |
next i | |
loadfloatarray xin, "asd.txt" | |
for i=0 to 28 | |
if xin[i] > -99 | |
set_node_output first_node(input), xin[i] | |
updategrid output | |
ms_delay 200 | |
plot float(xin[i], node_output(first_node(output)), LBLUE | |
ug | |
endif | |
next i | |
return |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
dg 4,1, LINEAR_NODE_TYPE | |
mg Grid1 | |
dg 1,1, STANDARD_NODE_TYPE | |
mg Grid2 | |
connectnodes nth_node(Grid1, 0), nth_node(Grid1, 1) | |
connectnodes nth_node(Grid1, 1), nth_node(Grid1, 2) | |
connectnodes nth_node(Grid1, 2), nth_node(Grid1, 3) | |
connectnodes nth_node(Grid1, 3), nth_node(Grid1, 0) | |
connectnodes nth_node(Grid1, 3), nth_node(Grid2, 0) | |
set_weights 0.95 | |
float inputs[4] | |
loadfloatarray inputs, "TEST1.DAT" | |
int i = 0 | |
for i=0 to 3 | |
set_node_output nth_node(Grid1, i), inputs[i] | |
next i | |
set_node_output first_node(Grid2), 0.5 | |
drawgrid Grid1 | |
drawgrid Grid2 | |
drawwires | |
// graph | |
graph_default_gridtype 0 | |
graph_default_axislabel "Input:", "Output" | |
graph_default_range 0, 0, 99, 1 | |
makegraph third_node_output | |
graph_active third_node_output | |
updatemode SYNCHRONOUS | |
for i=0 to 99 | |
updategrid Grid1 | |
updategrid Grid2 | |
drawgrid Grid1 | |
drawgrid Grid2 | |
plot float(i), node_output(nth_node(Grid1, 2)), YELLOW | |
ms_delay 200 | |
next i | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment