Skip to content

Instantly share code, notes, and snippets.

@lukasbach
Created June 15, 2018 20:19
Show Gist options
  • Save lukasbach/8532335b623d270bbd8dcce6992e687c to your computer and use it in GitHub Desktop.
Save lukasbach/8532335b623d270bbd8dcce6992e687c to your computer and use it in GitHub Desktop.
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