OpenNN
Open-source neural networks library
Loading...
Searching...
No Matches
flatten_layer.h
Go to the documentation of this file.
1// OpenNN: Open Neural Networks Library
2// www.opennn.net
3//
4// F L A T T E 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 Flatten final : public Layer
19{
20public:
21
23 Flatten(const Shape& = {});
24
26 Shape get_output_shape() const override { return { input_shape.size() }; }
27
29 void set(const Shape&);
30
32 void set_input_shape(const Shape& new_input_shape) override { set(new_input_shape); }
33
34private:
35
36 FlatOp flat;
37};
38
39}
40
41// OpenNN: Open Neural Networks Library.
42// Copyright(C) 2005-2026 Artificial Intelligence Techniques, SL.
43// Licensed under the GNU Lesser General Public License v2.1 or later.
void set(const Shape &)
Reconfigures the layer with a new input shape.
Flatten(const Shape &={})
Constructs a flatten layer for the given input shape.
void set_input_shape(const Shape &new_input_shape) override
Sets the input shape; subclasses override to derive dependent dimensions.
Definition flatten_layer.h:32
Shape get_output_shape() const override
Returns the flattened 1D output shape (product of input dimensions).
Definition flatten_layer.h:26
Layer()=default
Shape input_shape
Definition layer.h:256
Definition adaptive_moment_estimation.h:14
Flattens a multi-dimensional tensor into a 2D (batch, features) tensor.
Definition operators.h:995
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42