Demo entry 6350125

blue

   

Submitted by anonymous on Mar 06, 2017 at 11:32
Language: Python. Code size: 711 Bytes.

from numpy import exp, array, random, dot
import numpy as np
training_set_inputs = array([[36.8, 24.8],[31.8, 21.3],[43.8, 27.9],[36.8, 24.8],[32.1, 21.6],[45.1, 31.8],[35.9, 22.9],[32.1, 21.6]])
training_set_inputs = training_set_inputs/100
training_set_outputs = array([[0.765, 0.482, 1.162, 0.737, 0.482, 1.389, 0.652, 0.454]]).T
random.seed(1)
synaptic_weights = 2 * random.random((2, 1)) - 1
for iteration in xrange(1000):
	output = 1 / (1 + exp(-(dot(training_set_inputs, synaptic_weights))))
	synaptic_weights += dot(training_set_inputs.T, (training_set_outputs - output) * output * (1 - output))
	
print synaptic_weights
print 1/(1 + exp(-(dot(array([0.368, 0.25]), synaptic_weights))))*1000

This snippet took 0.00 seconds to highlight.

Back to the Entry List or Home.

Delete this entry (admin only).