diff --git a/include/cenet/layers/dense.hpp b/include/cenet/layers/dense.hpp index a05e9d3..34fb6b1 100644 --- a/include/cenet/layers/dense.hpp +++ b/include/cenet/layers/dense.hpp @@ -160,6 +160,43 @@ private: }; }; +class relu final : public layer_info { + template + friend class network; +private: + template + struct inner final { + using input_type = typename input_type_s::type; + using output_type = input_type; + + typename input_type::template with_storage retained; + + struct gradient { + void reset() {} + }; + + void dump(std::ostream& os) const {} + + void load(std::istream& is) {} + + template + void fill_random(const Dist& dist) {} + + template + auto feed(Fwd&& fwd) { + retained = std::forward(fwd); + return retained.apply([](auto in) { return in > 0.0 ? in : 0.0; }); + } + + template + auto backward(gradient& grad, Error prevErr) const { + return prevErr.apply(retained, [](auto in, auto check) { return check > 0.0 ? in : 0.0; }); + } + + void apply_grad(gradient&, double, double) {} + }; +}; + } // namespace layers } // namespace cenet