pub trait FilterLayer {
    // Required methods
    fn calculate_output_shape(&self, input_shape: &[usize]) -> Vec<usize>;
    fn num_spatial_dims(&self, input_shape: &[usize]) -> usize;
    fn filter_shape(&self) -> &[usize];
    fn stride(&self) -> &[usize];
    fn padding(&self) -> &[usize];

    // Provided methods
    fn calculate_spatial_output_dims(
        input_dims: &[usize],
        filter_dims: &[usize],
        padding: &[usize],
        stride: &[usize]
    ) -> Vec<usize> { ... }
    fn spatial_filter_dims(&self, num_spatial_dims: usize) -> Vec<usize> { ... }
    fn stride_dims(&self, num_spatial_dims: usize) -> Vec<usize> { ... }
    fn padding_dims(&self, num_spatial_dims: usize) -> Vec<usize> { ... }
}
Expand description

Provides common utilities for Layers that utilize a filter with stride and padding.

This is used by the Convolution and Pooling layers.

Required Methods§

source

fn calculate_output_shape(&self, input_shape: &[usize]) -> Vec<usize>

Calculate output shape based on the shape of filter, padding, stride and input.

source

fn num_spatial_dims(&self, input_shape: &[usize]) -> usize

Calculates the number of spatial dimensions for the pooling operation.

source

fn filter_shape(&self) -> &[usize]

The filter_shape that will be used by spatial_filter_dims.

source

fn stride(&self) -> &[usize]

The stride that will be used by stride_dims.

source

fn padding(&self) -> &[usize]

The padding that will be used by padding_dims.

Provided Methods§

source

fn calculate_spatial_output_dims( input_dims: &[usize], filter_dims: &[usize], padding: &[usize], stride: &[usize] ) -> Vec<usize>

Computes the shape of the spatial dimensions.

source

fn spatial_filter_dims(&self, num_spatial_dims: usize) -> Vec<usize>

Retrievs the spatial dimensions for the filter based on self.filter_shape() and the number of spatial dimensions.

The spatial dimensions only make up part of the whole filter shape. The other parts are the number of input and output feature maps.

source

fn stride_dims(&self, num_spatial_dims: usize) -> Vec<usize>

Retrievs the stride for the convolution based on self.stride and the number of spatial dimensions.

source

fn padding_dims(&self, num_spatial_dims: usize) -> Vec<usize>

Retrievs the padding for the convolution based on self.padding and the number of spatial dimensions.

Object Safety§

This trait is not object safe.

Implementors§