Skip to main content

max_pool

Function max_pool 

Source
pub fn max_pool<B: Backend, T: Float>(
    x: &Array<B, T>,
    window_shape: &[usize],
    strides: Option<&[usize]>,
    padding: impl Into<Padding>,
) -> Array<B, T>
Expand description

The maximum over windows of the spatial dimensions of an input (*batch, spatial..., features) (flax.linen.max_pool; strides of 1 for None).

§Examples

use ruxla_core::lax::Padding;
use ruxla_core::{Array, Native};

let x = Array::<Native, f32>::from_vec(vec![1.0, 5.0, 2.0, 4.0], [1, 4, 1]);
let y = ruxla_nn::max_pool(&x, &[2], Some(&[2]), Padding::Valid);
assert_eq!(y.to_vec(), [5.0, 4.0]);

§Panics

Panics if the window does not fit the input.