This file contains 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
function printImage(network) { | |
for(let y = 0; y < 6; y++) { | |
let row = [] | |
for(let x = 0; x < 8; x++) { | |
row.push(Math.round(network.activate([x,y]) )) | |
} | |
console.log(row.join(",")) | |
} | |
} |
This file contains 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
const learningRate = .3; | |
let image = [ | |
0,0,0,0,0,0,0,1, | |
0,0,0,0,0,0,1,0, | |
0,0,1,1,1,1,0,0, | |
0,0,1,1,1,1,0,0, | |
0,0,1,1,1,1,0,0, | |
0,0,0,0,0,0,0,0, |
This file contains 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
const synaptic = require('synaptic'); | |
const Layer = synaptic.Layer, | |
Network = synaptic.Network; | |
const inputLayer = new Layer(2); | |
const hiddenLayer = new Layer(15); | |
const outputLayer = new Layer(1) | |
inputLayer.project(hiddenLayer); |
This file contains 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
try { | |
const result = await asyncAction(); | |
} catch (err) { | |
console.log(err) | |
} |
This file contains 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
const asyncAction = () => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('Async action completed'); | |
}, 1000); | |
}); | |
}; | |
async function foo() { | |
try { |
This file contains 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
const asyncAction = () => { | |
return new Promise((resolve, reject) => { | |
setTimeout(() => { | |
resolve('Async action completed'); | |
}, 1000); | |
}); | |
}; | |
asyncAction() | |
.then(result => console.log(result)) |
This file contains 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
function1( () => { | |
function2(() => { | |
function3(() => { | |
function4(() => { | |
console.log("all done!") | |
}) | |
}) | |
}) | |
}) |
This file contains 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
const fs = require("fs"); | |
fs.readFile("./test1.js", (err, content) => { | |
if(err) { | |
return console.log(err); | |
} | |
console.log(content.toString()); | |
}) |
This file contains 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
console.log(1) | |
console.log(2) | |
setTimeout(() => { | |
console.log(3) | |
}, 100) | |
console.log(4) | |
console.log("N") |
This file contains 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
instruction1(); | |
instruction2(); | |
longRunningTask( () => { | |
instruction3(); | |
}); | |
instruction4(); | |
//... | |
instructionN(); |