31 const Shape& = {3, 3, 1, 1},
32 const string& =
"Identity",
33 const Shape& = {1, 1},
34 const string& =
"Valid",
36 const string& =
"convolutional_layer");
83 const Shape& = {3, 3, 1, 1},
84 const string& =
"Identity",
85 const Shape& = {1, 1},
86 const string& =
"Valid",
88 const string& =
"convolutional_layer");
116 Index input_height = 0;
117 Index input_width = 0;
118 Index input_channels = 0;
120 Index kernels_number = 0;
121 Index kernel_height = 0;
122 Index kernel_width = 0;
123 Index kernel_channels = 0;
125 Index row_stride = 1;
126 Index column_stride = 1;
128 bool use_padding =
false;
134 enum Forward {Input, ConvolutionView, BatchNormMean, BatchNormInverseVariance, Output};
136 void update_convolution_operator();
ActivationOp::Function get_activation_function() const
Definition convolutional_layer.h:73
Shape get_input_shape() const override
Returns the input tensor shape (height, width, channels).
Definition convolutional_layer.h:39
void set_row_stride(const Index)
void on_compute_dtype_changed() override
Rebuilds the convolution operator when the compute dtype changes.
Definition convolutional_layer.h:94
Shape get_output_shape() const override
Returns the output tensor shape after convolution.
ActivationOp::Function get_output_activation() const override
Returns the layer's output activation (Identity for most layers; overridden by Dense/Bounding).
Definition convolutional_layer.h:74
Index get_kernel_height() const
Definition convolutional_layer.h:54
void set_convolution_type(const string &)
Sets convolution type ("Valid" or "Same") and updates padding.
void read_JSON_body(const Json *) override
Reads the layer configuration from a JSON node.
Index get_output_height() const
Returns the output feature map height.
void set_activation_function(const string &)
Sets the activation function by name.
void set_batch_normalization(bool)
Enables or disables batch normalization after the convolution.
Index get_input_channels() const
bool get_batch_normalization() const
Definition convolutional_layer.h:76
void write_JSON_body(JsonWriter &) const override
Writes the layer configuration to a JSON writer.
Index get_padding_width() const
Returns the padding applied along the width axis.
vector< TensorSpec > get_forward_specs(Index batch_size) const override
Returns the tensor specifications used during forward propagation.
Index get_column_stride() const
Definition convolutional_layer.h:60
void set_column_stride(const Index)
Index get_kernel_channels() const
Definition convolutional_layer.h:56
void set_input_shape(const Shape &) override
Updates the layer for a new input shape and reinitializes derived sizes.
Convolutional(const Shape &={3, 3, 1}, const Shape &={3, 3, 1, 1}, const string &="Identity", const Shape &={1, 1}, const string &="Valid", bool=false, const string &="convolutional_layer")
Constructs a convolutional layer with the given shapes and activation.
Index get_kernels_number() const
Definition convolutional_layer.h:57
Index get_row_stride() const
Definition convolutional_layer.h:59
Index get_input_height() const
Index get_output_width() const
Returns the output feature map width.
void set(const Shape &={0, 0, 0}, const Shape &={3, 3, 1, 1}, const string &="Identity", const Shape &={1, 1}, const string &="Valid", bool=false, const string &="convolutional_layer")
Reconfigures the layer with new shapes and parameters.
bool get_use_padding() const
Definition convolutional_layer.h:71
Index get_padding_height() const
Returns the padding applied along the height axis.
pair< Index, Index > get_padding() const
Returns padding along height and width (in that order).
Index get_input_width() const
Index get_kernel_width() const
Definition convolutional_layer.h:55
Definition adaptive_moment_estimation.h:14
Element-wise non-linear activation (Identity, Sigmoid, Tanh, ReLU, Softmax).
Definition operators.h:169
Function
Supported activation functions.
Definition operators.h:171
Batch normalization with learnable scale/shift and running statistics for inference.
Definition operators.h:308
2D convolution operator (NHWC layout) backed by Eigen on CPU and cuDNN on GPU.
Definition operators.h:397
Fixed-capacity small-vector describing tensor dimensions (rank up to MaxRank).
Definition tensor_utilities.h:42