Loading...
Searching...
No Matches
opennn::Convolutional Class Referencefinal

#include <opennn/network/layers/convolutional_layer.h>

Inheritance diagram for opennn::Convolutional:
opennn::Layer

Public Member Functions

 Convolutional (const Shape &={3, 3, 1}, const Shape &={3, 3, 1, 1}, const string &="Identity", const Shape &={1, 1}, const string &="Valid", BatchNormalization=BatchNormalization::No, const string &="convolutional_layer")
 
Shape get_input_shape () const noexcept override
 
Shape get_output_shape () const override
 
Index get_output_height () const
 
Index get_output_width () const
 
Index get_kernel_height () const noexcept
 
Index get_kernel_width () const noexcept
 
Index get_kernel_channels () const noexcept
 
Index get_kernels_number () const noexcept
 
Index get_row_stride () const noexcept
 
Index get_column_stride () const noexcept
 
Index get_padding_height () const
 
Index get_padding_width () const
 
ActivationFunction get_activation_function () const noexcept
 
ActivationFunction get_output_activation () const noexcept override
 
bool get_batch_normalization () const
 
void get_folded_parameters (vector< float > &kernel_oihw, vector< float > &bias) const
 
bool get_residual () const noexcept
 
Index get_sources_number () const noexcept override
 
void set_residual (bool new_residual)
 
vector< TensorSpec > get_forward_specs (Index) const override
 
vector< TensorSpec > get_backward_specs (Index) const override
 
bool backward_uses_forward_output () const noexcept override
 
bool backward_uses_input (size_t input) const noexcept override
 
ForwardSlotKind get_forward_slot_kind (size_t slot) const override
 
bool is_forward_slot_inference_elidable (size_t slot, Device device) const noexcept override
 
bool folds_input_delta_addend (size_t input) const noexcept override
 
size_t get_recomputable_forward_slot () const noexcept override
 
void recompute_forward_slot (ForwardPropagation &, size_t) override
 
void set (const Shape &={0, 0, 0}, const Shape &={3, 3, 1, 1}, const string &="Identity", const Shape &={1, 1}, const string &="Valid", BatchNormalization=BatchNormalization::No, const string &="convolutional_layer")
 
bool accepts_input_rank (Index rank) const override
 
void apply_input_shape (const Shape &) override
 
void on_compute_dtype_changed () override
 
void set_activation_function (const string &)
 
void set_batch_normalization (bool new_batch_normalization)
 
void load_darknet_weights (FILE *)
 
void load_onnx_folded_conv_bn (const float *kernel_nchw, const float *folded_bias)
 
void load_onnx_conv_bias (const float *bias, const float *kernel_nchw)
 
void reinit_onnx_cls_out (float prior_bias)
 
void read_JSON_body (const Json *) override
 
void write_JSON_body (JsonWriter &) const override
 
void on_loaded () override
 
void forward_propagate (ForwardPropagation &, size_t, ForwardPropagationMode) override
 
- Public Member Functions inherited from opennn::Layer
virtual ~Layer ()=default
 
const string & get_label () const noexcept
 
const string & get_name () const
 
LayerType get_type () const noexcept
 
void set_input_shape (const Shape &new_input_shape)
 
virtual void set_output_shape (const Shape &)
 
void set_label (string new_label)
 
Index get_parameters_number () const
 
const vector< Operator * > & get_operators () const noexcept
 
virtual vector< TensorSpec > get_parameter_specs () const
 
virtual vector< TensorSpec > get_state_specs () const
 
virtual bool preserves_output_delta_during_backward () const noexcept
 
virtual bool allows_input_delta_alias () const noexcept
 
virtual bool allows_successors () const noexcept
 
virtual bool is_recurrent () const noexcept
 
virtual bool skip_for_pre_scaled_input () const noexcept
 
virtual bool uses_sequence_position () const noexcept
 
virtual bool allows_bf16_input_cast (size_t) const noexcept
 
Index get_inputs_number () const noexcept
 
Index get_outputs_number () const
 
virtual void back_propagate (ForwardPropagation &forward_propagation, BackPropagation &back_propagation, size_t i) const
 
virtual void from_JSON (const JsonDocument &)
 
virtual void load_state_from_JSON (const JsonDocument &)
 
virtual void to_JSON (JsonWriter &) const
 
virtual string write_expression (const vector< string > &, const vector< string > &) const
 
bool get_is_trainable () const noexcept
 
void set_is_trainable (bool trainable)
 
Type get_compute_dtype () const noexcept
 
Device get_compute_device () const noexcept
 
void set_compute_dtype (Type new_compute_dtype)
 
void set_compute_device (Device new_compute_device)
 
virtual float * link_states (float *, Device)
 
float * link_gradients (float *, Device)
 
vector< TensorView > & get_parameter_views ()
 
const vector< TensorView > & get_parameter_views () const noexcept
 
vector< TensorView > & get_parameter_scales ()
 
const vector< TensorView > & get_parameter_scales () const noexcept
 
vector< Operator::SlotQuantization > get_parameter_quantization () const
 
virtual TiedWeight get_tied_weight () const
 
virtual void set_tied_weight (const TiedWeight &tied_weight)
 
void redistribute_parameters_to_operators ()
 

Additional Inherited Members

- Protected Types inherited from opennn::Layer
enum  Forward { Input , Output }
 
- Protected Member Functions inherited from opennn::Layer
 Layer (LayerType type, Trainability trainability=Trainability::Trainable)
 
float * link_views_to_operators (vector< TensorView > &, float *, vector< TensorSpec >(Operator::*specs_fn)() const, void(Operator::*link_fn)(span< const TensorView >), Device)
 
- Static Protected Member Functions inherited from opennn::Layer
static bool refresh_feature_storage (Buffer &storage, bool &dirty, Device device, Index features, Index columns, const function< void(float *)> &fill)
 
- Protected Attributes inherited from opennn::Layer
string label = "my_layer"
 
bool is_trainable = true
 
Shape input_shape
 
Type compute_dtype = Type::FP32
 
Type weights_dtype = Type::FP32
 
Device compute_device = Device::CPU
 
vector< TensorView > parameters
 
vector< TensorView > parameter_scales
 
vector< TensorView > states
 
vector< Operator * > operators
 

Constructor & Destructor Documentation

◆ Convolutional()

opennn::Convolutional::Convolutional ( const Shape & = {3, 3, 1},
const Shape & = {3, 3, 1, 1},
const string & = "Identity",
const Shape & = {1, 1},
const string & = "Valid",
BatchNormalization = BatchNormalization::No,
const string & = "convolutional_layer" )

Member Function Documentation

◆ accepts_input_rank()

bool opennn::Convolutional::accepts_input_rank ( Index rank) const
inlineoverridevirtual

Reimplemented from opennn::Layer.

◆ apply_input_shape()

void opennn::Convolutional::apply_input_shape ( const Shape & )
overridevirtual

Reimplemented from opennn::Layer.

◆ backward_uses_forward_output()

bool opennn::Convolutional::backward_uses_forward_output ( ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ backward_uses_input()

bool opennn::Convolutional::backward_uses_input ( size_t input) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ folds_input_delta_addend()

bool opennn::Convolutional::folds_input_delta_addend ( size_t input) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ forward_propagate()

void opennn::Convolutional::forward_propagate ( ForwardPropagation & ,
size_t ,
ForwardPropagationMode  )
overridevirtual

Reimplemented from opennn::Layer.

◆ get_activation_function()

ActivationFunction opennn::Convolutional::get_activation_function ( ) const
inlinenoexcept

◆ get_backward_specs()

vector< TensorSpec > opennn::Convolutional::get_backward_specs ( Index ) const
overridevirtual

Reimplemented from opennn::Layer.

◆ get_batch_normalization()

bool opennn::Convolutional::get_batch_normalization ( ) const
inline

◆ get_column_stride()

Index opennn::Convolutional::get_column_stride ( ) const
inlinenoexcept

◆ get_folded_parameters()

void opennn::Convolutional::get_folded_parameters ( vector< float > & kernel_oihw,
vector< float > & bias ) const

◆ get_forward_slot_kind()

ForwardSlotKind opennn::Convolutional::get_forward_slot_kind ( size_t slot) const
inlineoverridevirtual

Reimplemented from opennn::Layer.

◆ get_forward_specs()

vector< TensorSpec > opennn::Convolutional::get_forward_specs ( Index ) const
overridevirtual

Reimplemented from opennn::Layer.

◆ get_input_shape()

Shape opennn::Convolutional::get_input_shape ( ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ get_kernel_channels()

Index opennn::Convolutional::get_kernel_channels ( ) const
inlinenoexcept

◆ get_kernel_height()

Index opennn::Convolutional::get_kernel_height ( ) const
inlinenoexcept

◆ get_kernel_width()

Index opennn::Convolutional::get_kernel_width ( ) const
inlinenoexcept

◆ get_kernels_number()

Index opennn::Convolutional::get_kernels_number ( ) const
inlinenoexcept

◆ get_output_activation()

ActivationFunction opennn::Convolutional::get_output_activation ( ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ get_output_height()

Index opennn::Convolutional::get_output_height ( ) const

◆ get_output_shape()

Shape opennn::Convolutional::get_output_shape ( ) const
overridevirtual

Implements opennn::Layer.

◆ get_output_width()

Index opennn::Convolutional::get_output_width ( ) const

◆ get_padding_height()

Index opennn::Convolutional::get_padding_height ( ) const

◆ get_padding_width()

Index opennn::Convolutional::get_padding_width ( ) const

◆ get_recomputable_forward_slot()

size_t opennn::Convolutional::get_recomputable_forward_slot ( ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ get_residual()

bool opennn::Convolutional::get_residual ( ) const
inlinenoexcept

◆ get_row_stride()

Index opennn::Convolutional::get_row_stride ( ) const
inlinenoexcept

◆ get_sources_number()

Index opennn::Convolutional::get_sources_number ( ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ is_forward_slot_inference_elidable()

bool opennn::Convolutional::is_forward_slot_inference_elidable ( size_t slot,
Device device ) const
inlineoverridevirtualnoexcept

Reimplemented from opennn::Layer.

◆ load_darknet_weights()

void opennn::Convolutional::load_darknet_weights ( FILE * )

◆ load_onnx_conv_bias()

void opennn::Convolutional::load_onnx_conv_bias ( const float * bias,
const float * kernel_nchw )

◆ load_onnx_folded_conv_bn()

void opennn::Convolutional::load_onnx_folded_conv_bn ( const float * kernel_nchw,
const float * folded_bias )

◆ on_compute_dtype_changed()

void opennn::Convolutional::on_compute_dtype_changed ( )
inlineoverridevirtual

Reimplemented from opennn::Layer.

◆ on_loaded()

void opennn::Convolutional::on_loaded ( )
inlineoverridevirtual

Reimplemented from opennn::Layer.

◆ read_JSON_body()

void opennn::Convolutional::read_JSON_body ( const Json * )
overridevirtual

Reimplemented from opennn::Layer.

◆ recompute_forward_slot()

void opennn::Convolutional::recompute_forward_slot ( ForwardPropagation & ,
size_t  )
overridevirtual

Reimplemented from opennn::Layer.

◆ reinit_onnx_cls_out()

void opennn::Convolutional::reinit_onnx_cls_out ( float prior_bias)

◆ set()

void opennn::Convolutional::set ( const Shape & = {0, 0, 0},
const Shape & = {3, 3, 1, 1},
const string & = "Identity",
const Shape & = {1, 1},
const string & = "Valid",
BatchNormalization = BatchNormalization::No,
const string & = "convolutional_layer" )

◆ set_activation_function()

void opennn::Convolutional::set_activation_function ( const string & )

◆ set_batch_normalization()

void opennn::Convolutional::set_batch_normalization ( bool new_batch_normalization)

◆ set_residual()

void opennn::Convolutional::set_residual ( bool new_residual)

◆ write_JSON_body()

void opennn::Convolutional::write_JSON_body ( JsonWriter & ) const
overridevirtual

Reimplemented from opennn::Layer.