Skip to content

Commit 785f0b9

Browse files
fohx13pavanky
authored andcommitted
Add ELU layer
1 parent 49bfb8e commit 785f0b9

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

include/af/nn/Modules/Activations.hpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,5 +58,16 @@ namespace af
5858
autograd::Variable forward(const autograd::Variable &input);
5959
};
6060

61+
class ELU : public Module
62+
{
63+
private:
64+
double m_alpha;
65+
public:
66+
ELU(double alpha = 1.0);
67+
68+
autograd::Variable forward(const autograd::Variable &input);
69+
};
70+
71+
6172
}
6273
}

src/nn/Modules/Activations.cpp

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,5 +67,16 @@ namespace af
6767

6868
}
6969

70+
ELU::ELU(double alpha) :
71+
m_alpha(alpha)
72+
{
73+
}
74+
75+
Variable ELU::forward(const Variable &input)
76+
{
77+
auto res = max(input, m_alpha * (exp(input) - 1));
78+
return res;
79+
}
80+
7081
}
7182
}

0 commit comments

Comments
 (0)