49 const Shape& kernel_shape = {3, 3, 1, 1},
50 const Shape& strides = {1, 1},
51 const string& convolution_type =
"Valid",
52 const string&
label =
"convolutional_relu_layer");
124 const Shape& kernel_shape = {3, 3, 1, 1},
125 const Shape& strides = {1, 1},
126 const string& convolution_type =
"Valid",
127 const string&
label =
"convolutional_relu_layer");
182 Index input_height = 0;
184 Index input_width = 0;
186 Index input_channels = 0;
189 Index kernels_number = 0;
191 Index kernel_height = 0;
193 Index kernel_width = 0;
195 Index kernel_channels = 0;
198 Index row_stride = 1;
200 Index column_stride = 1;
203 bool use_padding =
false;
211 enum Forward {Input, Output};
213 enum Backward {OutputDelta, InputDelta};
216 void update_convolution_operator();
Index get_padding_height() const
Padding rows added on each side.
Shape get_input_shape() const override
Returns the per-sample input shape (height, width, channels).
Definition convolutional_relu_layer.h:55
void back_propagate(ForwardPropagation &, BackPropagation &, size_t) const noexcept override
Backward pass through the fused ReLU and Convolution operators.
Activation::Function get_output_activation() const override
Activation function fused at the end of this layer (always ReLU).
Definition convolutional_relu_layer.h:103
Shape get_output_shape() const override
Returns the per-sample output shape.
pair< Index, Index > get_padding() const
Returns padding sizes for the configured convolution type.
Definition convolutional_relu_layer.h:93
void set_input_shape(const Shape &) override
Updates the input shape and re-shapes kernel tensors accordingly.
Index get_kernel_height() const
Kernel height in pixels.
Definition convolutional_relu_layer.h:76
Index get_row_stride() const
Vertical stride in pixels.
Definition convolutional_relu_layer.h:85
Index get_input_height() const
Configured input height.
Definition convolutional_relu_layer.h:69
void set(const Shape &input_shape={0, 0, 0}, const Shape &kernel_shape={3, 3, 1, 1}, const Shape &strides={1, 1}, const string &convolution_type="Valid", const string &label="convolutional_relu_layer")
Re-initializes the layer; same arguments as the constructor.
Index get_output_width() const
Output spatial width after applying stride and padding.
void set_row_stride(const Index new_row_stride)
Sets the vertical (row) stride.
Index get_input_width() const
Configured input width.
Definition convolutional_relu_layer.h:71
Index get_kernel_width() const
Kernel width in pixels.
Definition convolutional_relu_layer.h:78
void write_JSON_body(JsonWriter &) const override
Writes the layer-specific JSON body (kernel shape, strides, padding) to the given JSON writer.
void read_JSON_body(const Json *) override
Reads the layer-specific JSON body (kernel shape, strides, padding) from the given JSON node.
Index get_kernels_number() const
Number of kernels (output channel count).
Definition convolutional_relu_layer.h:82
Index get_padding_width() const
Padding columns added on each side.
void set_column_stride(const Index new_column_stride)
Sets the horizontal (column) stride.
vector< pair< Shape, Type > > get_forward_specs(Index batch_size) const override
Specifications of the forward intermediate buffers.
void on_compute_dtype_changed() override
Recreates the convolution operator descriptor when the dtype changes.
Definition convolutional_relu_layer.h:132
Index get_column_stride() const
Horizontal stride in pixels.
Definition convolutional_relu_layer.h:87
void set_convolution_type(const string &)
Sets the padding mode by name.
Index get_output_height() const
Output spatial height after applying stride and padding.
ConvolutionalRelu(const Shape &input_shape={3, 3, 1}, const Shape &kernel_shape={3, 3, 1, 1}, const Shape &strides={1, 1}, const string &convolution_type="Valid", const string &label="convolutional_relu_layer")
Constructs a ConvolutionalRelu layer.
vector< Operator * > get_operators() override
Returns the single operator (Convolution with fused ReLU on GPU).
Definition convolutional_relu_layer.h:106
Index get_kernel_channels() const
Kernel channel count (must equal input channels).
Definition convolutional_relu_layer.h:80
Index get_input_channels() const
Configured input channel count.
Definition convolutional_relu_layer.h:73
bool get_use_padding() const
True if padding is applied (i.e. convolution type is not "Valid").
Definition convolutional_relu_layer.h:100
void forward_propagate(ForwardPropagation &, size_t, bool) noexcept override
Forward pass: convolution + ReLU fused on GPU, sequential on CPU.
Layer()=default
Default constructor; only invoked by subclasses.
string label
User-visible label for this layer instance (default "my_layer").
Definition layer.h:469
Declares the Layer abstract base class and the LayerType enumeration.
Definition adaptive_moment_estimation.h:19
Definition operators.h:107
Function
Definition operators.h:108
@ ReLU
Definition operators.h:108
Definition back_propagation.h:26
Definition operators.h:275
Definition forward_propagation.h:19
Definition tensor_utilities.h:46