RTNeural  1.0.0
Real-time neural inferencing library
Public Member Functions | Public Attributes | List of all members
Conv2D< T > Class Template Reference

Dynamic implementation of a 2-dimensional convolution layer with no activation. More...

+ Inheritance diagram for Conv2D< T >:

Public Member Functions

 Conv2D (int in_num_filters_in, int in_num_filters_out, int in_num_features_in, int in_kernel_size_time, int in_kernel_size_feature, int in_dilation_rate, int in_stride, bool in_valid_pad)
 
 Conv2D (std::initializer_list< int > sizes)
 
 Conv2D (const Conv2D &other)
 
Conv2Doperator= (const Conv2D &other)
 
virtual ~Conv2D ()=default
 
RTNEURAL_REALTIME void reset () override
 Reset the layer's state. More...
 
std::string getName () const noexcept override
 Returns the name of this layer. More...
 
constexpr bool isActivation () const noexcept
 Returns false since convolution is not an activation layer. More...
 
RTNEURAL_REALTIME void forward (const T *input, T *output) noexcept override
 Performs forward propagation for this layer. More...
 
RTNEURAL_REALTIME void setWeights (const std::vector< std::vector< std::vector< std::vector< T >>>> &inWeights)
 Sets the layer weights. More...
 
RTNEURAL_REALTIME void setBias (const std::vector< T > &inBias)
 Sets the layer biases. More...
 
RTNEURAL_REALTIME int getKernelSizeTime () const noexcept
 Returns the size of the convolution kernel (time axis). More...
 
RTNEURAL_REALTIME int getKernelSizeFeature () const noexcept
 Returns the size of the convolution kernel (feature axis). More...
 
RTNEURAL_REALTIME int getStride () const noexcept
 Returns the convolution stride (feature axis) More...
 
RTNEURAL_REALTIME int getDilationRate () const noexcept
 Returns the convolution dilation rate (time axis) More...
 
- Public Member Functions inherited from Layer< T >
 Layer (int in_size, int out_size)
 Constructs a layer with given input and output size. More...
 
virtual ~Layer ()=default
 

Public Attributes

const int num_filters_in
 
const int num_features_in
 
const int num_filters_out
 
const int kernel_size_time
 
const int kernel_size_feature
 
const int dilation_rate
 
const int stride
 
const int num_features_out
 
const int receptive_field
 
const bool valid_pad
 
- Public Attributes inherited from Layer< T >
const int in_size
 
const int out_size
 

Detailed Description

template<typename T>
class RTNEURAL_NAMESPACE::Conv2D< T >

Dynamic implementation of a 2-dimensional convolution layer with no activation.

Template Parameters
TType of the layer (float, double, int ...)

Constructor & Destructor Documentation

◆ Conv2D() [1/3]

Conv2D ( int  in_num_filters_in,
int  in_num_filters_out,
int  in_num_features_in,
int  in_kernel_size_time,
int  in_kernel_size_feature,
int  in_dilation_rate,
int  in_stride,
bool  in_valid_pad 
)
Parameters
in_num_filters_innumber of input filters (channels)
in_num_filters_outnumber of output filters (channels)
in_num_features_innumber of input features
in_kernel_size_timesize of the convolution kernel (time axis)
in_kernel_size_featuresize of the convolution kernel (feature axis)
in_dilation_ratedilation_rate (time axis)
in_strideconvolution stride (feature axis)
in_valid_padwhether the padding is "valid" or not ("same" otherwise)

◆ Conv2D() [2/3]

Conv2D ( std::initializer_list< int >  sizes)

◆ Conv2D() [3/3]

Conv2D ( const Conv2D< T > &  other)

◆ ~Conv2D()

virtual ~Conv2D ( )
virtualdefault

Member Function Documentation

◆ operator=()

Conv2D& operator= ( const Conv2D< T > &  other)

◆ reset()

RTNEURAL_REALTIME void reset ( )
overridevirtual

Reset the layer's state.

Reimplemented from Layer< T >.

References Conv2D< T >::receptive_field.

◆ getName()

std::string getName ( ) const
overridevirtualnoexcept

Returns the name of this layer.

Reimplemented from Layer< T >.

◆ isActivation()

constexpr bool isActivation ( ) const
constexprnoexcept

Returns false since convolution is not an activation layer.

◆ forward()

RTNEURAL_REALTIME void forward ( const T *  input,
T *  output 
)
overridevirtualnoexcept

◆ setWeights()

RTNEURAL_REALTIME void setWeights ( const std::vector< std::vector< std::vector< std::vector< T >>>> &  inWeights)

Sets the layer weights.

The weights vector must have size weights[num_filters_out][num_filters_in][kernel_size]

◆ setBias()

RTNEURAL_REALTIME void setBias ( const std::vector< T > &  inBias)

Sets the layer biases.

The bias vector must have size bias[num_filters_out]

◆ getKernelSizeTime()

RTNEURAL_REALTIME int getKernelSizeTime ( ) const
noexcept

Returns the size of the convolution kernel (time axis).

References Conv2D< T >::kernel_size_time.

◆ getKernelSizeFeature()

RTNEURAL_REALTIME int getKernelSizeFeature ( ) const
noexcept

Returns the size of the convolution kernel (feature axis).

References Conv2D< T >::kernel_size_feature.

◆ getStride()

RTNEURAL_REALTIME int getStride ( ) const
noexcept

Returns the convolution stride (feature axis)

References Conv2D< T >::stride.

◆ getDilationRate()

RTNEURAL_REALTIME int getDilationRate ( ) const
noexcept

Returns the convolution dilation rate (time axis)

References Conv2D< T >::dilation_rate.

Member Data Documentation

◆ num_filters_in

const int num_filters_in

◆ num_features_in

const int num_features_in

◆ num_filters_out

const int num_filters_out

Referenced by Conv2D< T >::forward().

◆ kernel_size_time

const int kernel_size_time

◆ kernel_size_feature

const int kernel_size_feature

◆ dilation_rate

const int dilation_rate

◆ stride

const int stride

Referenced by Conv2D< T >::getStride().

◆ num_features_out

const int num_features_out

Referenced by Conv2D< T >::forward().

◆ receptive_field

const int receptive_field

◆ valid_pad

const bool valid_pad

The documentation for this class was generated from the following file: