Skip to content

Commit 1a404d1

Browse files
committed
relu special case with simple lambda
1 parent 5f26c03 commit 1a404d1

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

include/fdeep/layers/relu_layer.hpp

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88

99
#include "fdeep/layers/activation_layer.hpp"
1010

11+
#include <algorithm>
12+
#include <limits>
1113
#include <string>
1214

1315
namespace fdeep {
@@ -29,6 +31,13 @@ namespace internal {
2931
protected:
3032
tensor transform_input(const tensor& in_vol) const override
3133
{
34+
if (negative_slope_ == static_cast<float_type>(0) &&
35+
threshold_ == static_cast<float_type>(0) &&
36+
max_value_ == std::numeric_limits<float_type>::max()) {
37+
return transform_tensor([](float_type x) -> float_type {
38+
return std::max(static_cast<float_type>(0), x);
39+
}, in_vol);
40+
}
3241
return transform_tensor([&](float_type x) -> float_type {
3342
if (x >= max_value_)
3443
return max_value_;

0 commit comments

Comments
 (0)