pub struct Interpolate2d {
pub output_size: Option<[usize; 2]>,
pub scale_factor: Option<[f32; 2]>,
pub mode: Ignored<InterpolateMode>,
}Expand description
Interpolate module for resizing tensors with shape [N, C, H, W].
This struct represents an interpolation module that can resize tensors using various interpolation methods. It provides flexibility in specifying either an output size or a scale factor for resizing, along with options for the interpolation mode.
The module can be used to upsample or downsample tensors, preserving the number of channels and batch size while adjusting the height and width dimensions.
The module can be created using the Interpolate2dConfig struct and the
init method, which returns an instance of the Interpolate2d struct.
Fields§
§output_size: Option<[usize; 2]>Output size of the interpolated tensor
scale_factor: Option<[f32; 2]>Scale factor for resizing the input tensor
mode: Ignored<InterpolateMode>Interpolation mode used for resizing
Implementations§
Source§impl Interpolate2d
impl Interpolate2d
Sourcepub fn forward<B>(&self, input: Tensor<B, 4>) -> Tensor<B, 4>where
B: Backend,
pub fn forward<B>(&self, input: Tensor<B, 4>) -> Tensor<B, 4>where
B: Backend,
Performs the forward pass of the interpolation module
§Arguments
input- Input tensor with shape [N, C, H, W]
§Returns
Resized tensor with shape [N, C, H’, W’], where H’ and W’ are determined by the output_size or scale_factor specified in the module configuration
§Example
let input = Tensor::<Backend, 2>::random([1, 3, 64, 64], Distribution::Uniform(0.0, 1.0), &device);
let interpolate = Interpolate2dConfig::new()
.with_output_size(Some([128, 128]))
.init();
let output = interpolate.forward(input);
assert_eq!(output.dims(), [1, 3, 128, 128]);Trait Implementations§
Source§impl<B> AutodiffModule<B> for Interpolate2dwhere
B: AutodiffBackend,
impl<B> AutodiffModule<B> for Interpolate2dwhere
B: AutodiffBackend,
Source§type InnerModule = Interpolate2d
type InnerModule = Interpolate2d
Source§fn valid(&self) -> <Interpolate2d as AutodiffModule<B>>::InnerModule
fn valid(&self) -> <Interpolate2d as AutodiffModule<B>>::InnerModule
Source§impl Clone for Interpolate2d
impl Clone for Interpolate2d
Source§fn clone(&self) -> Interpolate2d
fn clone(&self) -> Interpolate2d
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Interpolate2d
impl Debug for Interpolate2d
Source§impl Display for Interpolate2d
impl Display for Interpolate2d
Source§impl<B> Module<B> for Interpolate2dwhere
B: Backend,
impl<B> Module<B> for Interpolate2dwhere
B: Backend,
Source§type Record = ConstantRecord
type Record = ConstantRecord
Source§fn visit<V>(&self, _visitor: &mut V)where
V: ModuleVisitor<B>,
fn visit<V>(&self, _visitor: &mut V)where
V: ModuleVisitor<B>,
Source§fn map<M>(self, _mapper: &mut M) -> Interpolate2dwhere
M: ModuleMapper<B>,
fn map<M>(self, _mapper: &mut M) -> Interpolate2dwhere
M: ModuleMapper<B>,
Source§fn load_record(
self,
_record: <Interpolate2d as Module<B>>::Record,
) -> Interpolate2d
fn load_record( self, _record: <Interpolate2d as Module<B>>::Record, ) -> Interpolate2d
Source§fn into_record(self) -> <Interpolate2d as Module<B>>::Record
fn into_record(self) -> <Interpolate2d as Module<B>>::Record
Source§fn to_device(self, _: &<B as Backend>::Device) -> Interpolate2d
fn to_device(self, _: &<B as Backend>::Device) -> Interpolate2d
Source§fn fork(self, _: &<B as Backend>::Device) -> Interpolate2d
fn fork(self, _: &<B as Backend>::Device) -> Interpolate2d
Source§fn collect_devices(
&self,
devices: Vec<<B as Backend>::Device>,
) -> Vec<<B as Backend>::Device>
fn collect_devices( &self, devices: Vec<<B as Backend>::Device>, ) -> Vec<<B as Backend>::Device>
Source§fn devices(&self) -> Vec<<B as Backend>::Device>
fn devices(&self) -> Vec<<B as Backend>::Device>
Source§fn num_params(&self) -> usize
fn num_params(&self) -> usize
Source§fn save_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
) -> Result<(), RecorderError>
fn save_file<FR, PB>( self, file_path: PB, recorder: &FR, ) -> Result<(), RecorderError>
Source§fn load_file<FR, PB>(
self,
file_path: PB,
recorder: &FR,
device: &<B as Backend>::Device,
) -> Result<Self, RecorderError>
fn load_file<FR, PB>( self, file_path: PB, recorder: &FR, device: &<B as Backend>::Device, ) -> Result<Self, RecorderError>
Source§fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
fn quantize_weights(self, quantizer: &mut Quantizer) -> Self
Source§impl ModuleDisplay for Interpolate2d
impl ModuleDisplay for Interpolate2d
Source§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
Source§impl ModuleDisplayDefault for Interpolate2d
impl ModuleDisplayDefault for Interpolate2d
Auto Trait Implementations§
impl Freeze for Interpolate2d
impl RefUnwindSafe for Interpolate2d
impl Send for Interpolate2d
impl Sync for Interpolate2d
impl Unpin for Interpolate2d
impl UnwindSafe for Interpolate2d
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more