Loading...
Searching...
No Matches
flatten_layer.h
Go to the documentation of this file.
1// SPDX-License-Identifier: AGPL-3.0-only
2// Copyright (C) 2026 Artificial Intelligence Techniques, S.L. and Roberto López González
3
4#pragma once
5
7
8namespace opennn
9{
10
11class Flatten final : public Layer
12{
13public:
14
15 Flatten(const Shape& = {}, const string& = "flatten_layer");
16
17 Shape get_output_shape() const override { return { input_shape.size() }; }
18
19 vector<TensorSpec> get_forward_specs(Index) const override { return {}; }
20
21 vector<TensorSpec> get_backward_specs(Index) const override { return {}; }
22
23 void set(const Shape&, const string& = "flatten_layer");
24
25 bool accepts_input_rank(Index rank) const override { return is_one_of(rank, 1, 2, 3); }
26
27 void apply_input_shape(const Shape& new_input_shape) override { set(new_input_shape, label); }
28};
29
30}
void set(const Shape &, const string &="flatten_layer")
void apply_input_shape(const Shape &new_input_shape) override
Definition flatten_layer.h:27
vector< TensorSpec > get_forward_specs(Index) const override
Definition flatten_layer.h:19
vector< TensorSpec > get_backward_specs(Index) const override
Definition flatten_layer.h:21
Flatten(const Shape &={}, const string &="flatten_layer")
Shape get_output_shape() const override
Definition flatten_layer.h:17
bool accepts_input_rank(Index rank) const override
Definition flatten_layer.h:25
string label
Definition layer.h:215
Layer(LayerType type, Trainability trainability=Trainability::Trainable)
Definition layer.h:210
Shape input_shape
Definition layer.h:219
Definition configuration.h:10
constexpr bool is_one_of(const T &value, const Candidates &... candidates)
Definition opennn_types.h:273
Definition tensor_types.h:172