-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathLoss.py
More file actions
30 lines (17 loc) · 674 Bytes
/
Loss.py
File metadata and controls
30 lines (17 loc) · 674 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
# Author : V I S H W A S [https://github.com/vstark21]
import numpy as np
# Loss helper class used in neural network
class Loss:
def __init__(self, loss_type="mse"):
self.loss_type = loss_type
def back_prop(self, y_pred, y_true):
"""
This function starts back prop
"""
if self.loss_type == "mse":
dA = 2 * (y_pred - y_true)
elif self.loss_type == "binary_crossentropy":
dA = np.divide(y_pred - y_true, y_pred - np.power(y_pred, 2))
elif self.loss_type == "categorical_crossentropy":
dA = y_pred - y_true
return dA