-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLossFunction.py
More file actions
33 lines (26 loc) · 756 Bytes
/
LossFunction.py
File metadata and controls
33 lines (26 loc) · 756 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
28
29
30
31
32
33
import math
class LossFunction:
RELU = "relu"
SIGMOID = "sigmoid"
TANH = "tanh"
HEAVISIDE = "heaviside"
@staticmethod
def heaviside(x):
return 1 if x >= 0 else 0
@staticmethod
def sigmoid(x):
return 1 / (1 + math.exp(-x))
@staticmethod
def tanh(x):
return (math.exp(x) - math.exp(-x)) / (math.exp(x) + math.exp(-x))
@staticmethod
def relu(x):
return x if x >= 0 else 0
@staticmethod
def loss_methods_switch_process():
return {
LossFunction.RELU: LossFunction.relu,
LossFunction.TANH: LossFunction.tanh,
LossFunction.SIGMOID: LossFunction.sigmoid,
LossFunction.HEAVISIDE: LossFunction.heaviside,
}