pub struct PoolConfig {
pub kernel_size: Vec<usize>,
pub stride: Vec<usize>,
pub padding: Vec<usize>,
pub ceil_mode: bool,
}Expand description
Pooling configuration specifying kernel size, stride, padding, and rounding mode.
Fields§
§kernel_size: Vec<usize>Kernel (window) size for each spatial dimension.
stride: Vec<usize>Stride for each spatial dimension. If empty, defaults to kernel_size.
padding: Vec<usize>Zero-padding on each side for each spatial dimension.
ceil_mode: boolUse ceil instead of floor for output size computation.
Implementations§
Source§impl PoolConfig
impl PoolConfig
Sourcepub fn new(kernel_size: Vec<usize>) -> Self
pub fn new(kernel_size: Vec<usize>) -> Self
Create a new config with the given kernel size, stride equal to kernel size, zero padding, and floor mode.
Sourcepub fn with_stride(self, stride: Vec<usize>) -> Self
pub fn with_stride(self, stride: Vec<usize>) -> Self
Set the stride (builder pattern).
Sourcepub fn with_padding(self, padding: Vec<usize>) -> Self
pub fn with_padding(self, padding: Vec<usize>) -> Self
Set the padding (builder pattern).
Sourcepub fn with_ceil_mode(self, ceil: bool) -> Self
pub fn with_ceil_mode(self, ceil: bool) -> Self
Set ceil mode (builder pattern).
Sourcepub fn output_size(&self, input_size: usize, dim: usize) -> usize
pub fn output_size(&self, input_size: usize, dim: usize) -> usize
Compute the output size for one spatial dimension.
Formula: floor((input + 2*padding - kernel) / stride) + 1
(or ceil if ceil_mode is true).
Sourcepub fn validate(&self) -> Result<(), PoolingError>
pub fn validate(&self) -> Result<(), PoolingError>
Validate the config, returning an error if any field is invalid.
Sourcepub fn num_spatial_dims(&self) -> usize
pub fn num_spatial_dims(&self) -> usize
Number of spatial dimensions this config covers.
Trait Implementations§
Source§impl Clone for PoolConfig
impl Clone for PoolConfig
Source§fn clone(&self) -> PoolConfig
fn clone(&self) -> PoolConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PoolConfig
impl RefUnwindSafe for PoolConfig
impl Send for PoolConfig
impl Sync for PoolConfig
impl Unpin for PoolConfig
impl UnsafeUnpin for PoolConfig
impl UnwindSafe for PoolConfig
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