OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
addition_layer.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// A D D I T I O N 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 Addition final : public Layer
19{
20public:
21
23 Addition(const Shape& = {}, const string& = "");
24
25 Shape get_output_shape() const override { return input_shape; }
26
28 vector<TensorSpec> get_backward_specs(Index batch_size) const override;
29
31 void set(const Shape&, const string&);
33 void set_input_shape(const Shape& shape) override { set(shape, label); }
34
35private:
36
37 AddOp add;
38
39 enum Backward {OutputDelta, InputDelta0, InputDelta1};
40};
41
42}
43
44// OpenNN: Open Neural Networks Library.
45// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
46// Licensed under the GNU Lesser General Public License v2.1 or later.
void set(const Shape &, const string &)
Reconfigures the layer with a new input shape and label.
vector< TensorSpec > get_backward_specs(Index batch_size) const override
Returns the tensor specs of intermediate backward buffers for a given batch size.
Shape get_output_shape() const override
Returns the output shape; subclasses must implement this to expose their geometry.
Definition addition_layer.h:25
void set_input_shape(const Shape &shape) override
Sets the input shape; subclasses override to derive dependent dimensions.
Definition addition_layer.h:33
Addition(const Shape &={}, const string &="")
Constructs an addition layer for the given input shape and label.
Layer()=default
string label
Definition layer.h:250
Shape input_shape
Definition layer.h:256
Definition adaptive_moment_estimation.h:14
void add(const TensorView &input_1, const TensorView &input_2, TensorView &output)
Element-wise addition: output = input_1 + input_2.
Element-wise sum of several input tensors (used by residual connections).
Definition operators.h:110
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42