fork download
  1.  
  2. def mp_neuron(inputs, weights,threshold):
  3. threshold = 2
  4. output = []
  5. for (x1,x2) in inputs:
  6. total = x1*weights[0]+x2*weights[1]
  7. output.append(1 if total >= threshold else 0)
  8. return list(output)
  9.  
  10. inputs = [(0, 0), (0, 1), (1, 0), (1, 1)]
  11. expected = [0, 0, 0, 1]
  12. weights = [1,1]
  13.  
  14. print("AND Gate")
  15. threshold = 2
  16. print("Actual Output: ", expected)
  17. print("Predicted Output:", mp_neuron(inputs, weights, threshold))
  18.  
  19.  
  20.  
  21.  
Success #stdin #stdout 0.05s 63492KB
stdin
Standard input is empty
stdout
AND Gate
('Actual Output: ', [0, 0, 0, 1])
('Predicted Output:', [0, 0, 0, 1])