Created
June 15, 2018 20:19
-
-
Save lukasbach/8532335b623d270bbd8dcce6992e687c 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
let funRun = (w1, w2, b) => { | |
let obj = {}; | |
obj.ga1 = w1 * -0.4 + w2 * 0.5 + b; | |
obj.ga2 = w1 * -0.8 + w2 * (-0.2) + b; | |
obj.gb1 = w1 * 0.5 + w2 * 1.2 + b; | |
obj.gb2 = w1 * -0.4 + w2 * 2.5 + b; | |
return obj; | |
} | |
nextIter = (w1, w2, b) => { | |
let obj = funRun(w1, w2, b); | |
if (obj.ga1 < 0) { | |
w1 += -0.4; | |
w2 += 0.5; | |
b += 1; | |
} | |
if (obj.ga2 < 0) { | |
w1 += -0.8; | |
w2 += -0.2; | |
b += 1; | |
} | |
if (obj.gb1 > 0) { | |
w1 -= 0.5; | |
w2 -= 1.2; | |
b -= 1; | |
} | |
if (obj.gb2 > 0) { | |
w1 -= -0.4; | |
w2 -= 2.5; | |
b -= 1; | |
} | |
return {w1, w2, b, obj}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment