CInterpolationLayer Class
May 24, 2022 ยท View on GitHub
The class implements a layer that changes the sizes of some axes of the blob and fills the new elements with interpolated values.
At this moment only linear interpolation is supported.
Settings
Dimension sizes
void SetRule( TBlobDim dim, const CRule& rule );
Sets the rule to be used when calculating the size of dim blob dimension.
It's recommended to use one of these functions to create the CRule:
CInterpolationLayer::CRule::Resize( int newSize )to set thedimof the output tonewSizeCInterpolationLayer::CRule::Scale( float scale )to multiply thedimbyscale(relative to the input blob).
By default layer doesn't change any of the dimensions.
Coordinate system
void SetCoords( TInterpolationCoords newCoords );
Sets the way layer calculates the coordinates of the new elements xNew relative to the elements of the input xOld.
Supported values:
TInterpolationCoords::HalfPixel-xOld = ( xNew + 0.5 ) / scale - 0.5TInterpolationCoords::PytorchHalfPixel-xOld = ( newSize > 1 ) ? ( xNew + 0.5 ) / scale - 0.5 : 0TInterpolationCoords::AlignCorners-xOld = xNew * ( oldSize - 1 ) / ( newSize - 1 )TInterpolationCoords::Asymmetric-xOld = xNew / scalewhere:oldSizeandnewSizeare the sizes of the dimension before and after the transformationscale- coefficient used to multiply input dimension (newSize / oldSizein case of fixed output size)
By default TInterpolationCoords::Asymmetric is used.
Coordinate rounding
void SetRound( TInterpolationRound newRound );
Sets how the coordinates xOld are rounded. If used then every element of the output will be one of the elements of the input (no interpolated values).
Supported values:
TInterpolationRound::None- don't round, calculate interpolated valuesTInterpolationRound::RoundPreferFloor- less or equal to the half values are rounded downTInterpolationRound::RoundPreferCeil- less than half values are rounded downTInterpolationRound::Floor- zeroing non-integer partTInterpolationRound::Ceil- if non-integer part is present, it's rounded up.
By default rounding is not used (TInterpolationRound::None).
Trainable parameters
There are no trainable parameters for this layer.
Inputs
The single input accepts a blob of any size.
Outputs
The single output contains a blob where each dim size is calculated based on GetRule( dim ).