Struct burn::nn::interpolate::Interpolate1d
pub struct Interpolate1d {
pub output_size: Option<usize>,
pub scale_factor: Option<f32>,
pub mode: Ignored<InterpolateMode>,
}
Expand description
Interpolate module for resizing 1D tensors with shape [N, C, L].
This struct represents a 1D 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 1D tensors, preserving the number of channels and batch size while adjusting the length dimension.
The module can be created using the Interpolate1dConfig struct and the
init
method, which returns an instance of the Interpolate1d struct.
Fields§
§output_size: Option<usize>
Output size of the interpolated tensor
scale_factor: Option<f32>
Scale factor for resizing the input tensor
mode: Ignored<InterpolateMode>
Interpolation mode used for resizing
Implementations§
§impl Interpolate1d
impl Interpolate1d
pub fn forward<B>(&self, input: Tensor<B, 3>) -> Tensor<B, 3>where
B: Backend,
pub fn forward<B>(&self, input: Tensor<B, 3>) -> Tensor<B, 3>where
B: Backend,
Performs the forward pass of the 1D interpolation module
§Arguments
input
- Input tensor with shape [N, C, L]
§Returns
Resized tensor with shape [N, C, L’], where L’ is determined by the output_size or scale_factor specified in the module configuration
§Example
let input = Tensor::<Backend, 3>::random([1, 3, 64], Distribution::Uniform(0.0, 1.0), &device);
let interpolate = Interpolate1dConfig::new()
.with_output_size(Some(128))
.init();
let output = interpolate.forward(input);
assert_eq!(output.dims(), [1, 3, 128]);
Trait Implementations§
§impl<B> AutodiffModule<B> for Interpolate1dwhere
B: AutodiffBackend,
impl<B> AutodiffModule<B> for Interpolate1dwhere
B: AutodiffBackend,
§type InnerModule = Interpolate1d
type InnerModule = Interpolate1d
§fn valid(&self) -> <Interpolate1d as AutodiffModule<B>>::InnerModule
fn valid(&self) -> <Interpolate1d as AutodiffModule<B>>::InnerModule
§impl Clone for Interpolate1d
impl Clone for Interpolate1d
§fn clone(&self) -> Interpolate1d
fn clone(&self) -> Interpolate1d
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read more§impl Debug for Interpolate1d
impl Debug for Interpolate1d
§impl Display for Interpolate1d
impl Display for Interpolate1d
§impl<B> Module<B> for Interpolate1dwhere
B: Backend,
impl<B> Module<B> for Interpolate1dwhere
B: Backend,
§type Record = ConstantRecord
type Record = ConstantRecord
§fn visit<V>(&self, _visitor: &mut V)where
V: ModuleVisitor<B>,
fn visit<V>(&self, _visitor: &mut V)where
V: ModuleVisitor<B>,
§fn map<M>(self, _mapper: &mut M) -> Interpolate1dwhere
M: ModuleMapper<B>,
fn map<M>(self, _mapper: &mut M) -> Interpolate1dwhere
M: ModuleMapper<B>,
§fn load_record(
self,
_record: <Interpolate1d as Module<B>>::Record,
) -> Interpolate1d
fn load_record( self, _record: <Interpolate1d as Module<B>>::Record, ) -> Interpolate1d
§fn into_record(self) -> <Interpolate1d as Module<B>>::Record
fn into_record(self) -> <Interpolate1d as Module<B>>::Record
§fn to_device(self, _: &<B as Backend>::Device) -> Interpolate1d
fn to_device(self, _: &<B as Backend>::Device) -> Interpolate1d
§fn fork(self, _: &<B as Backend>::Device) -> Interpolate1d
fn fork(self, _: &<B as Backend>::Device) -> Interpolate1d
§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>
§fn devices(&self) -> Vec<<B as Backend>::Device>
fn devices(&self) -> Vec<<B as Backend>::Device>
§fn num_params(&self) -> usize
fn num_params(&self) -> usize
§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>
§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>
§fn quantize_weights<C>(self, quantizer: &mut Quantizer<C>) -> Selfwhere
C: Calibration,
fn quantize_weights<C>(self, quantizer: &mut Quantizer<C>) -> Selfwhere
C: Calibration,
§impl ModuleDisplay for Interpolate1d
impl ModuleDisplay for Interpolate1d
§fn custom_settings(&self) -> Option<DisplaySettings>
fn custom_settings(&self) -> Option<DisplaySettings>
§fn custom_content(&self, content: Content) -> Option<Content>
fn custom_content(&self, content: Content) -> Option<Content>
§fn format(&self, passed_settings: DisplaySettings) -> String
fn format(&self, passed_settings: DisplaySettings) -> String
§impl ModuleDisplayDefault for Interpolate1d
impl ModuleDisplayDefault for Interpolate1d
Auto Trait Implementations§
impl Freeze for Interpolate1d
impl RefUnwindSafe for Interpolate1d
impl Send for Interpolate1d
impl Sync for Interpolate1d
impl Unpin for Interpolate1d
impl UnwindSafe for Interpolate1d
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§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> ToCompactString for Twhere
T: Display,
impl<T> ToCompactString for Twhere
T: Display,
§fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
fn try_to_compact_string(&self) -> Result<CompactString, ToCompactStringError>
ToCompactString::to_compact_string()
] Read more§fn to_compact_string(&self) -> CompactString
fn to_compact_string(&self) -> CompactString
CompactString
]. Read more