Exemple #1
0
	def testSteepness(self):
		sigmoid = Sigmoid()
		
		inp = random.random()
		greaterInp = inp * 1.1
		
		value = sigmoid.evaluate(inp)
		greaterValue = sigmoid.evaluate(greaterInp)
		self.assertGreater(greaterValue, value)
Exemple #2
0
	def testOffset(self):
		offset = random.randint(0,10)
		steepness = random.randint(1,10)
		sigmoid = Sigmoid(steepness, offset)
		
		offsetValue = sigmoid.evaluate(-offset)
		offsetTarget = 1/2
		targetRatio = offsetValue / offsetTarget
		
		self.assertLess(targetRatio, 1.1)
		self.assertGreater(targetRatio, 0.9)
Exemple #3
0
class Neuron:
	
	def __init__(self, previousRow):
		self.weightedNeurons = getWeightedNeurons(previousRow)
		self.sigmoid = Sigmoid()

	def evaluate(self):
		sum = 0
		for weightedNeuron in self.weightedNeurons:
			sum += weightedNeuron.evaluate()
		if len(self.weightedNeurons) > 0:
			sum /= len(self.weightedNeurons)
		return self.sigmoid.evaluate(sum)