Loading...
Searching...
No Matches
upsampling_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
8
9namespace opennn
10{
11
13{
14 Index input_height = 0;
15 Index input_width = 0;
16 Index channels = 0;
17 Index scale_factor = 2;
18
19 void set(Index, Index, Index, Index);
20
22 void back_propagate(ForwardPropagation&, BackPropagation&, size_t) const override;
23};
24
25class Upsampling final : public Layer
26{
27public:
28
29 Upsampling(const Shape& = {},
30 Index scale_factor = 2,
31 const string& = "upsampling_layer");
32
33 Shape get_output_shape() const override;
34
35 void set(const Shape&, Index, const string&);
36 bool accepts_input_rank(Index rank) const override { return is_one_of(rank, 3); }
37
39 {
41 "{} layer supports FP32 activations only; compile the network with Type::FP32.",
42 get_name());
43 }
44
45 void apply_input_shape(const Shape& new_input_shape) override { set(new_input_shape, upsampling.scale_factor, label); }
46 void set_scale_factor(Index);
47
48 void read_JSON_body(const Json*) override;
49 void write_JSON_body(JsonWriter&) const override;
50
51private:
52
53 UpsamplingOperator upsampling;
54
55 void configure_operator();
56};
57
58}
Definition json.h:92
Definition json.h:24
Type get_compute_dtype() const noexcept
Definition layer.h:157
string label
Definition layer.h:215
Layer(LayerType type, Trainability trainability=Trainability::Trainable)
Definition layer.h:210
const string & get_name() const
void read_JSON_body(const Json *) override
void set(const Shape &, Index, const string &)
Shape get_output_shape() const override
bool accepts_input_rank(Index rank) const override
Definition upsampling_layer.h:36
void write_JSON_body(JsonWriter &) const override
Upsampling(const Shape &={}, Index scale_factor=2, const string &="upsampling_layer")
void apply_input_shape(const Shape &new_input_shape) override
Definition upsampling_layer.h:45
void on_compute_dtype_changed() override
Definition upsampling_layer.h:38
void set_scale_factor(Index)
Definition configuration.h:10
constexpr bool is_one_of(const T &value, const Candidates &... candidates)
Definition opennn_types.h:273
@ FP32
Definition configuration.h:13
ForwardPropagationMode
Definition forward_propagation.h:33
#define throw_if(condition,...)
Definition opennn_types.h:243
Definition back_propagation.h:19
Definition forward_propagation.h:52
Definition operator.h:28
Definition tensor_types.h:172
Definition upsampling_layer.h:13
Index scale_factor
Definition upsampling_layer.h:17
Index input_height
Definition upsampling_layer.h:14
Index input_width
Definition upsampling_layer.h:15
void forward_propagate(ForwardPropagation &, size_t, ForwardPropagationMode) override
void set(Index, Index, Index, Index)
Index channels
Definition upsampling_layer.h:16
void back_propagate(ForwardPropagation &, BackPropagation &, size_t) const override