-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlayers.py
34 lines (28 loc) · 997 Bytes
/
layers.py
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
28
29
30
31
32
33
34
from activ_funcs import *
class Dense:
def __init__(self, nodes, name="d", activation="sig"):
self.nodes = nodes
self.name = name
self.activ_name = activation
def activation(self, x):
if (self.activ_name == "sig"):
return sigmoid(x)
elif (self.activ_name == "tanh"):
return tanh(x)
elif (self.activ_name == "relu"):
return ReLU(x)
else:
#By default use sigmoid
return sigmoid(x)
def d_activation(self, x):
if (self.activ_name == "sig"):
return d_sigmoid(x)
elif (self.activ_name == "tanh"):
return d_tanh(x)
elif (self.activ_name == "relu"):
return d_ReLU(x)
else:
#By default use derivative of sigmoid
return d_sigmoid(x)
def to_string(self):
return self.name + "|" + str(self.nodes) + "|" + self.activ_name