Trait juice::layers::common::FilterLayer
source · 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§
sourcefn calculate_output_shape(&self, input_shape: &[usize]) -> Vec<usize>
fn calculate_output_shape(&self, input_shape: &[usize]) -> Vec<usize>
Calculate output shape based on the shape of filter, padding, stride and input.
sourcefn num_spatial_dims(&self, input_shape: &[usize]) -> usize
fn num_spatial_dims(&self, input_shape: &[usize]) -> usize
Calculates the number of spatial dimensions for the pooling operation.
sourcefn filter_shape(&self) -> &[usize]
fn filter_shape(&self) -> &[usize]
The filter_shape that will be used by spatial_filter_dims
.
Provided Methods§
sourcefn calculate_spatial_output_dims(
input_dims: &[usize],
filter_dims: &[usize],
padding: &[usize],
stride: &[usize]
) -> Vec<usize>
fn calculate_spatial_output_dims( input_dims: &[usize], filter_dims: &[usize], padding: &[usize], stride: &[usize] ) -> Vec<usize>
Computes the shape of the spatial dimensions.
sourcefn spatial_filter_dims(&self, num_spatial_dims: usize) -> Vec<usize>
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.
sourcefn stride_dims(&self, num_spatial_dims: usize) -> Vec<usize>
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.
sourcefn padding_dims(&self, num_spatial_dims: usize) -> Vec<usize>
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.