Neural network

Because I've just seen a video on youtube about neural network and deep learning.

Log in to post a comment.

// You can find the Turtle API reference here: https://turtletoy.net/syntax
Canvas.setpenopacity(0.2);

const size = 90;            //min = 10, max = 100, step = 5
const neurons = 16;         //min = 2, max = 32, step = 1
const layers = 4;           //min = 2, max = 8, step = 1
const horizontal = 0;       //min = 0, max = 1, step = 1, (no, yes)

// Global code will be evaluated once.
const turtle = new Turtle();

let lines = [];
let increment = 2 * size / (neurons - 1);
for(let i = -size; i <= size; i+=increment){
    lines.push(i);
}

let x = -size;

// The walk function will be called until it returns false.
function walk(i) {
    for(let y1 of lines){
        for(let y2 of lines){
            turtle.jump(x, y1);
            turtle.goto(x + 2*size / (layers-1), y2);
            if(horizontal){
                turtle.jump(y1, x);
                turtle.goto(y2, x + 2*size / (layers-1));
            }
        }
    }
    
    x += 2*size / (layers-1);
    if(x >= size) return false;
    return true;
}