Add activation method, fix printing

This commit is contained in:
George Lacey 2017-02-09 19:06:01 +00:00
parent 4edf73d674
commit 9e8d0d2906

View File

@ -1,18 +1,32 @@
from Input import Input
class Perceptron(object):
def __init__(self):
self.inputs = {}
def print(self):
for key, value in self.inputs:
print("%s - )") % key
value.print()
for key in self.inputs:
print(key + ":")
self.inputs[key].print()
def addinput(self, p_name, p_value, p_weight):
def add_input(self, p_name, p_value, p_weight):
self.inputs[p_name] = Input(p_value, p_weight)
def setweight(self, p_input, p_weight):
def set_weight(self, p_input, p_weight):
self.inputs[p_input].weight = p_weight
def _sum_inputs(self):
total = 0
for key, value in self.inputs.items():
total += value.output()
return total
def activation(self):
input = self._sum_inputs()
print("Total = %f" % input)
if input > 0:
return True
else:
return False