-
Notifications
You must be signed in to change notification settings - Fork 1
/
lossFunc.py
57 lines (44 loc) · 1.34 KB
/
lossFunc.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
import torch
#######################################################
def mape_loss(true,pre):
dataabs = torch.abs(true - pre)
return torch.mean(dataabs / true)
#######################################################
def rmse_loss(true,pre):
# RMSE = np.sqrt(np.mean(np.square(true - pre)))
# .pow(2)
RMSE = (pre - true).norm(2)
return RMSE
#######################################################
#
def pinball_loss(q,labels,out):
# labels [batch,3,24]
labels = labels.reshape([-1, 1])
out = out.reshape([-1, 1])
lossout = 0
for count in range(labels.shape[0]):
if labels[count] > out[count]:
lossout = lossout + q*(labels[count] - out[count])
else:
lossout = lossout + (1-q)*(out[count] - labels[count])
return lossout
############################
def picp_loss(pre,upper,lower):
# labels [batch,3,24]
pre = pre.reshape([-1, 1])
upper = upper.reshape([-1, 1])
lower = lower.reshape([-1, 1])
picp = 0
for count in range(pre.shape[0]):
if pre[count] < upper[count] and pre[count] > lower[count]:
c = 1
else:
c = 0
########
picp = picp + c
picp = picp / ( 1.0 * pre.shape[0] )
return picp
############################
def ace(picp, pinc):
return picp - pinc
############################