OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
dense_relu_layer.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// D E N S E R E L U L A Y E R C L A S S H E A D E R
5//
6// Artificial Intelligence Techniques SL
7// artelnics@artelnics.com
8
9#pragma once
10
11#include "layer.h"
12#include "operators.h"
13
14namespace opennn
15{
16
18class DenseRelu final : public Layer
19{
20public:
21
23 DenseRelu(const Shape& = {},
24 const Shape& = {},
25 const string& = "dense_relu_layer");
26
28 Shape get_output_shape() const override;
29
30 Index get_input_features() const { return input_shape.empty() ? 0 : input_shape.back(); }
31 Index get_sequence_length() const { return (input_shape.rank == 2) ? input_shape[0] : Index(1); }
32
34
36 void set(const Shape& = {},
37 const Shape& = {},
38 const string& = "dense_relu_layer");
39
41 void set_input_shape(const Shape&) override;
43 void set_output_shape(const Shape&) override;
44 void on_compute_dtype_changed() override { configure_operators(); }
45
46private:
47
48 Index output_features = 0;
49
50 CombinationReluOp combination_relu;
51
52 void configure_operators();
53};
54
55}
56
57// OpenNN: Open Neural Networks Library.
58// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
59// Licensed under the GNU Lesser General Public License v2.1 or later.
Shape get_output_shape() const override
Returns the layer output shape, derived from input shape and configured output features.
void set_input_shape(const Shape &) override
Sets the input shape; subclasses override to derive dependent dimensions.
void set_output_shape(const Shape &) override
Sets the output shape; subclasses override when the output is user-configurable.
Index get_sequence_length() const
Definition dense_relu_layer.h:31
DenseRelu(const Shape &={}, const Shape &={}, const string &="dense_relu_layer")
Constructs a fused dense+ReLU layer with the given input and output shapes.
void set(const Shape &={}, const Shape &={}, const string &="dense_relu_layer")
Reconfigures the layer with new input/output shapes and label.
void on_compute_dtype_changed() override
Subclass hook invoked when the compute dtype changes; default is no-op.
Definition dense_relu_layer.h:44
Index get_input_features() const
Definition dense_relu_layer.h:30
ActivationOp::Function get_output_activation() const override
Returns the layer's output activation (Identity for most layers; overridden by Dense/Bounding).
Definition dense_relu_layer.h:33
Layer()=default
Shape input_shape
Definition layer.h:256
Definition adaptive_moment_estimation.h:14
Function
Supported activation functions.
Definition operators.h:171
@ ReLU
Definition operators.h:171
Fused affine + ReLU activation (uses cuBLASLt epilogue on GPU when available).
Definition operators.h:286
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42