// ///////////////////////////////////////////////////////////////////////////////////////// // BRAIN FUNCTIONS // TODO: implementar esses métodos em brainActions(). public void train() { for (int i = 0; i < repeat_teaching; i++) { float r = p.random(1); if (r < 0.25f) { brain.setInput(0, p.random(0.5f, 1f)); brain.setInput(1, p.random(0.5f, 1f)); brain.setDesiredOutput(0, 1f); brain.setDesiredOutput(1, 0f); brain.feedForward(); brain.backPropagate(); } else if (r >= 0.25f && r < 0.5f) { brain.setInput(0, p.random(0f, 0.5f)); brain.setInput(1, p.random(0f, 0.5f)); brain.setDesiredOutput(0, 0.5f); brain.setDesiredOutput(1, 0.5f); brain.feedForward(); brain.backPropagate(); } else if (r >= 0.5f && r < 0.75f) { brain.setInput(0, p.random(0.5f, 1f)); brain.setInput(1, p.random(0f, 0.5f)); brain.setDesiredOutput(0, 0.5f); brain.setDesiredOutput(1, 0.5f); brain.feedForward(); brain.backPropagate(); } else { brain.setInput(0, p.random(0f, 0.5f)); brain.setInput(1, p.random(0f, 0.5f)); brain.setDesiredOutput(0, 0f); brain.setDesiredOutput(1, 0f); brain.feedForward(); brain.backPropagate(); } } }
public void ask(float inOne, float inTwo) { brain.setInput(0, inOne); brain.setInput(1, inTwo); brain.feedForward(); // p.println(id + ": " + "output 0 " + brain.getOutput(0)); // p.println(id + ": " + "output 1 " + brain.getOutput(1)); }
/* * void teach(float getIn, float getOut, int i) { for (int i = 0; * i<repeat_teaching; i++) { brain.setInput(i, getIn); //recebe input * brain.setOutput(i.getOut);// e output brain.feedForward(); * brain.backPropagate(); // e "ensina" } } */ public void teach(float in, int i) { brain.setDesiredOutput(i, in); brain.feedForward(); brain.backPropagate(); }