-
Notifications
You must be signed in to change notification settings - Fork 22
Expand file tree
/
Copy pathLoss.hpp
More file actions
94 lines (75 loc) · 3.07 KB
/
Loss.hpp
File metadata and controls
94 lines (75 loc) · 3.07 KB
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/*******************************************************
* Copyright (c) 2017, ArrayFire
* All rights reserved.
*
* This file is distributed under 3-clause BSD license.
* The complete license agreement can be obtained at:
* http://arrayfire.com/licenses/BSD-3-Clause
********************************************************/
#pragma once
#include <af/nn/Modules/Module.hpp>
namespace af
{
namespace nn
{
class Loss : public Module
{
public:
Loss() {}
virtual autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets) = 0;
autograd::Variable forward(const autograd::Variable &inputs);
autograd::Variable operator()(const autograd::Variable &inputs,
const autograd::Variable &targets);
};
class MeanSquaredError : public Loss
{
public:
MeanSquaredError() {}
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets);
};
class MeanAbsoluteError : public Loss
{
public:
MeanAbsoluteError() {}
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets);
};
class BinaryCrossEntropyLoss : public Loss
{
public:
BinaryCrossEntropyLoss() {}
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets);
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets,
const autograd::Variable &weights);
};
class CrossEntropyLoss : public Loss
{
public:
CrossEntropyLoss() {}
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets);
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets,
const autograd::Variable &weights);
};
class MultiMarginLoss : public Loss
{
public:
MultiMarginLoss() {}
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets);
autograd::Variable forward(const autograd::Variable &inputs,
const autograd::Variable &targets,
const autograd::Variable &weights);
};
typedef MeanSquaredError MSE;
typedef MeanAbsoluteError MAE;
typedef MeanAbsoluteError L1Loss;
typedef BinaryCrossEntropyLoss BCELoss;
typedef CrossEntropyLoss CELoss;
}
}