OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
normalization_layer_3d.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// N O R M A L I Z A T I O N L A Y E R 3 D 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 Normalization3d final : public Layer
19{
20public:
21
25 Normalization3d(const Shape& = Shape({0,0}),
26 const string& = "normalization_layer_3d");
27
29 Shape get_input_shape() const override;
30
32 Shape get_output_shape() const override;
33
34 Index get_sequence_length() const { return sequence_length; }
35 Index get_embedding_dimension() const { return embedding_dimension; }
36
38 vector<TensorSpec> get_forward_specs(Index batch_size) const override;
39
41 void set(Index = 0, Index = 0, const string& = "normalization_layer_3d");
42
44 void set_input_shape(const Shape&) override;
45
47 void read_JSON_body(const Json*) override;
48
49private:
50
51 Index sequence_length = 0;
52 Index embedding_dimension = 0;
53
54 LayerNormOp layer_norm;
55
56 enum Forward {Input, Means, StandardDeviations, NormalizedInput, Output};
57};
58
59}
60
61// OpenNN: Open Neural Networks Library.
62// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
63// Licensed under the GNU Lesser General Public License v2.1 or later.
Definition json.h:23
Layer()=default
vector< TensorSpec > get_forward_specs(Index batch_size) const override
Returns the tensor specifications used during forward propagation.
Shape get_output_shape() const override
Returns the output tensor shape (same as input).
Index get_embedding_dimension() const
Definition normalization_layer_3d.h:35
Shape get_input_shape() const override
Returns the input tensor shape (sequence_length, embedding_dimension).
Index get_sequence_length() const
Definition normalization_layer_3d.h:34
void set(Index=0, Index=0, const string &="normalization_layer_3d")
Reconfigures the layer with new sequence length, embedding dimension and name.
void read_JSON_body(const Json *) override
Reads the layer configuration from a JSON node.
void set_input_shape(const Shape &) override
Updates the layer for a new input shape.
Normalization3d(const Shape &=Shape({0, 0}), const string &="normalization_layer_3d")
Constructs a 3D layer normalization layer.
Definition adaptive_moment_estimation.h:14
Layer normalization with learnable scale/shift, applied across the embedding dimension.
Definition operators.h:530
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42