-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathnode.py
More file actions
37 lines (21 loc) 路 689 Bytes
/
Copy pathnode.py
File metadata and controls
37 lines (21 loc) 路 689 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import math
class Node:
def __init__(self, id_number):
self.id = id_number
self.layer = 0
self.input_value = 0
self.output_value = 0
self.connections = []
def activate(self):
def sigmoid(x):
return 1/(1+math.exp(-x))
if self.layer == 1:
self.output_value = sigmoid(self.input_value)
for i in range(0, len(self.connections)):
self.connections[i].to_node.input_value += \
self.connections[i].weight * self.output_value
def clone(self):
clone = Node(self.id)
clone.id = self.id
clone.layer = self.layer
return clone