linear regression - A simple perceptron in Python -


http://en.wikipedia.org/wiki/perceptron#example

my question is, why there 3 input values in each vector when nand takes 2 parameters , returns 1:

http://en.wikipedia.org/wiki/sheffer_stroke#definition

pasted code convenience:

th = 0.1 learning_rate = 0.1 weights = [0, 0, 0] training_set = [((1, 0, 0), 1), ((1, 0, 1), 1), ((1, 1, 0), 1), ((1, 1, 1), 0)]  def sum_function(values):     return sum(value * weights[index] index, value in enumerate(values))  while true:     print '-' * 60     error_count = 0     input_vector, desired_output in training_set:         print weights         result = 1 if sum_function(input_vector) > th else 0         error = desired_output - result         if error != 0:             error_count += 1             index, value in enumerate(input_vector):                 weights[index] += learning_rate * error * value     if error_count == 0:         break 

it because need 1 value constant input. - known bias.

if notice have 3 weights well, first item in triple ( seems 1 ) should seen 'input 0', (the bias). constant.

i suggest having @ these videos on youtube: simple explanation of neural networks

hope helps


Comments

Popular posts from this blog

delphi - How to convert bitmaps to video? -

jasper reports - Fixed header in Excel using JasperReports -

python - ('The SQL contains 0 parameter markers, but 50 parameters were supplied', 'HY000') or TypeError: 'tuple' object is not callable -