pub struct AdaptiveAvgPool2d { /* private fields */ }Expand description
Adaptive 2D Average Pooling — pools to a fixed output size.
Automatically computes kernel_size, stride, and padding to produce the desired output spatial dimensions, regardless of input size.
Input: [N, C, H_in, W_in]
Output: [N, C, H_out, W_out]
Common use: AdaptiveAvgPool2d([1, 1]) — global average pooling.
Implementations§
Source§impl AdaptiveAvgPool2d
impl AdaptiveAvgPool2d
Sourcepub fn new(output_size: [usize; 2]) -> AdaptiveAvgPool2d
pub fn new(output_size: [usize; 2]) -> AdaptiveAvgPool2d
Create an AdaptiveAvgPool2d with the desired output spatial size.
Trait Implementations§
Source§impl<B> Module<B> for AdaptiveAvgPool2dwhere
B: Backend,
impl<B> Module<B> for AdaptiveAvgPool2dwhere
B: Backend,
Source§fn forward(&self, x: &Tensor<B>) -> Result<Tensor<B>, Error>
fn forward(&self, x: &Tensor<B>) -> Result<Tensor<B>, Error>
Compute the output tensor from the input tensor.
This defines the layer’s computation (forward pass).
Source§fn parameters(&self) -> Vec<Tensor<B>>
fn parameters(&self) -> Vec<Tensor<B>>
Return all trainable parameters of this module.
The optimizer uses these to update weights during training.
Source§fn set_training(&self, _training: bool)
fn set_training(&self, _training: bool)
Set training or evaluation mode. Read more
Source§fn is_training(&self) -> bool
fn is_training(&self) -> bool
Whether the module is in training mode (default: true).
Source§fn num_parameters(&self) -> usize
fn num_parameters(&self) -> usize
Total number of scalar parameters in this module.
Source§fn trainable_params_count(&self) -> usize
fn trainable_params_count(&self) -> usize
Number of trainable (variable) parameters.
Source§fn frozen_parameters(&self) -> Vec<Tensor<B>>
fn frozen_parameters(&self) -> Vec<Tensor<B>>
Freeze all parameters: returns new parameter tensors with
is_variable = false, preventing gradient accumulation. Read moreAuto Trait Implementations§
impl Freeze for AdaptiveAvgPool2d
impl RefUnwindSafe for AdaptiveAvgPool2d
impl Send for AdaptiveAvgPool2d
impl Sync for AdaptiveAvgPool2d
impl Unpin for AdaptiveAvgPool2d
impl UnwindSafe for AdaptiveAvgPool2d
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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