Trait coaster_nn::Pooling

source ·
pub trait Pooling<F>: NN<F> {
    // Required methods
    fn new_pooling_config(
        &self,
        window: &[i32],
        stride: &[i32],
        padding: &[i32]
    ) -> Result<Self::CPOOL, Error>;
    fn pooling_max(
        &self,
        x: &SharedTensor<F>,
        result: &mut SharedTensor<F>,
        config: &Self::CPOOL
    ) -> Result<(), Error>;
    fn pooling_max_grad(
        &self,
        x: &SharedTensor<F>,
        x_diff: &SharedTensor<F>,
        result: &SharedTensor<F>,
        result_diff: &mut SharedTensor<F>,
        config: &Self::CPOOL
    ) -> Result<(), Error>;
    fn pooling_avg(
        &self,
        x: &SharedTensor<F>,
        result: &mut SharedTensor<F>,
        config: &Self::CPOOL
    ) -> Result<(), Error>;
    fn pooling_avg_grad(
        &self,
        x: &SharedTensor<F>,
        x_diff: &SharedTensor<F>,
        result: &SharedTensor<F>,
        result_diff: &mut SharedTensor<F>,
        config: &Self::CPOOL
    ) -> Result<(), Error>;
}
Expand description

Provides the functionality for a Backend to support Pooling operations.

Required Methods§

source

fn new_pooling_config( &self, window: &[i32], stride: &[i32], padding: &[i32] ) -> Result<Self::CPOOL, Error>

Creates a new PoolingConfig, which needs to be passed to further pooling Operations.

source

fn pooling_max( &self, x: &SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL ) -> Result<(), Error>

Computes non-linear down-sampling ([max Pooling][pooling]) over the input Tensor x. [pooling]: https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer

Saves the result to result.

source

fn pooling_max_grad( &self, x: &SharedTensor<F>, x_diff: &SharedTensor<F>, result: &SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL ) -> Result<(), Error>

Computes the gradient of [max Pooling][pooling] over the input Tensor x. [pooling]: https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer

Saves the result to result_diff.

source

fn pooling_avg( &self, x: &SharedTensor<F>, result: &mut SharedTensor<F>, config: &Self::CPOOL ) -> Result<(), Error>

Computes non-linear down-sampling ([average Pooling][pooling]) over the input Tensor x. [pooling]: https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer

Saves the result to result.

source

fn pooling_avg_grad( &self, x: &SharedTensor<F>, x_diff: &SharedTensor<F>, result: &SharedTensor<F>, result_diff: &mut SharedTensor<F>, config: &Self::CPOOL ) -> Result<(), Error>

Computes the gradient of [average Pooling][pooling] over the input Tensor x. [pooling]: https://en.wikipedia.org/wiki/Convolutional_neural_network#Pooling_layer

Saves the result to result_diff.

Object Safety§

This trait is not object safe.

Implementations on Foreign Types§

source§

impl<T> Pooling<T> for Backend<Cuda>
where T: Float + Default + DataTypeInfo,

source§

fn new_pooling_config( &self, window: &[i32], stride: &[i32], padding: &[i32] ) -> Result<Self::CPOOL, Error>

source§

fn pooling_max( &self, x: &SharedTensor<T>, result: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_max_grad( &self, x: &SharedTensor<T>, x_diff: &SharedTensor<T>, result: &SharedTensor<T>, result_diff: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_avg( &self, x: &SharedTensor<T>, result: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_avg_grad( &self, x: &SharedTensor<T>, x_diff: &SharedTensor<T>, result: &SharedTensor<T>, result_diff: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

impl<T> Pooling<T> for Backend<Native>
where T: Add<T, Output = T> + Mul<T, Output = T> + Default + Copy + PartialOrd + Bounded,

source§

fn new_pooling_config( &self, window: &[i32], stride: &[i32], padding: &[i32] ) -> Result<Self::CPOOL, Error>

source§

fn pooling_max( &self, x: &SharedTensor<T>, result: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_max_grad( &self, x: &SharedTensor<T>, x_diff: &SharedTensor<T>, result: &SharedTensor<T>, result_diff: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_avg( &self, x: &SharedTensor<T>, result: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

source§

fn pooling_avg_grad( &self, x: &SharedTensor<T>, x_diff: &SharedTensor<T>, result: &SharedTensor<T>, result_diff: &mut SharedTensor<T>, config: &Self::CPOOL ) -> Result<(), Error>

Implementors§