-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpart_3_losses.cpp
More file actions
66 lines (47 loc) · 892 Bytes
/
part_3_losses.cpp
File metadata and controls
66 lines (47 loc) · 892 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <math.h>
using namespace std;
void mse()
{
double y[3] = {1,2,3};
double y_pred[3] = {1,2,3};
double sum=0;
for(int i=0; i <3; i++)
{
sum += pow((y[i] - y_pred[i]), 2);
}
sum /= 3;
cout<<"OUTPUT of mse : "<<sum;
cout<<"\n\nACcuracy of mse : "<<100 - sum;
}
void bce()
{
double y[1] = {0};
double y_pred[1] = {0.001};
double sum=0;
for(int i=0; i <1; i++)
{
sum += (y[i]*log(y_pred[i]) + ((1-y[i]) * log(1 - y_pred[i])));
}
sum = -sum;
sum /= 1;
cout<<"output of bce : "<<sum;
}
void cce()
{
double y[3] = {0,0,1};
double y_pred[3] = {0.5,0.1,0.1};
double sum=0;
for(int i=0; i<3; i++)
{
sum += y[i]*log(y_pred[i]);
}
sum = -sum;
sum /= 1;
cout<<"Output of cce : "<<sum;
}
int main()
{
cce();
return 0;
}