Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Neuron {
- Neuron [] m_inputs;
- float [] m_weights;
- float m_output;
- Neuron(){
- }
- Neuron(Neuron [] prev_inputs)
- {
- inputs = new Neuron [prev_inputs.length];
- weights = new float [prev_inputs.length];
- for (int i = 0; i < inputs.length; i++) {
- inputs[i] = prev_inputs[i];
- weights[i] = random(-1.0, 1.0);
- }
- }
- void respond() {
- float sum_input = 0.0;
- for (int i = 0; i < m_inputs.length; i++) {
- input += inputs[i].output * weights[i];
- }
- output = lookupSigmoid(sum_input);
- }
- void display() {
- fill(128 * (1 - output));
- ellipse(0, 0, 16, 16); // Draw the neuron
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment