def test_3(steps): weights = 1 print "Target converse {0}, {1} steps".format(weights, steps) neuron = Neuron(weights, sigm, sigmp, error) errors = [] for i in range(steps): inputs = [random.random() for r in range(weights)] target = 1.0 - inputs[0] neuron.learn_1(inputs, target) errors.append(neuron.last_error) print report(errors)
def test_1(steps): weights = 3 print "Linear combination of weights {0}, {1} steps".format(weights, steps) neuron = Neuron(weights, sigm, sigmp, error) errors = [] for i in range(steps): inputs = [random.random() for r in range(weights)] target = 2*inputs[0] + 0.3*inputs[1] - 0.7*inputs[2] neuron.learn_1(inputs, target) errors.append(neuron.last_error) print report(errors)
def test_5(steps): weights = 40 print "Target sqrt(avg) {0}, {1} steps".format(weights, steps) neuron = Neuron(weights, sigm, sigmp, error) errors = [] for i in range(steps): inputs = [random.random() for r in range(weights)] avg = sum(inputs)/len(inputs) target = math.sqrt(avg) neuron.learn_1(inputs, target) errors.append(neuron.last_error) print report(errors)
def test_4(steps): weights = 40 print "Target max - min {0}, {1} steps".format(weights, steps) neuron = Neuron(weights, sigm, sigmp, error) errors = [] for i in range(steps): inputs = [random.random() for r in range(weights)] imax = max(inputs) imin = min(inputs) target = imax - imin neuron.learn_1(inputs, target) errors.append(neuron.last_error) print report(errors)