SHOGUN  4.2.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
List of all members | Public Member Functions | Protected Member Functions | Protected Attributes
CConvolutionalFeatureMap Class Reference

Detailed Description

Handles convolution and gradient calculation for a single feature map in a convolutional neural network.

Definition at line 65 of file ConvolutionalFeatureMap.h.

Public Member Functions

 CConvolutionalFeatureMap (int32_t input_width, int32_t input_height, int32_t radius_x, int32_t radius_y, int32_t stride_x=1, int32_t stride_y=1, int32_t index=0, EConvMapActivationFunction function=CMAF_IDENTITY, ENLAutoencoderPosition autoencoder_position=NLAP_NONE)
 
void compute_activations (SGVector< float64_t > parameters, CDynamicObjectArray *layers, SGVector< int32_t > input_indices, SGMatrix< float64_t > activations)
 
void compute_gradients (SGVector< float64_t > parameters, SGMatrix< float64_t > activations, SGMatrix< float64_t > activation_gradients, CDynamicObjectArray *layers, SGVector< int32_t > input_indices, SGVector< float64_t > parameter_gradients)
 
void pool_activations (SGMatrix< float64_t > activations, int32_t pooling_width, int32_t pooling_height, SGMatrix< float64_t > pooled_activations, SGMatrix< float64_t > max_indices)
 

Protected Member Functions

void convolve (SGMatrix< float64_t > inputs, SGMatrix< float64_t > weights, SGMatrix< float64_t > outputs, bool flip, bool reset_output, int32_t inputs_row_offset, int32_t outputs_row_offset)
 
void compute_weight_gradients (SGMatrix< float64_t > inputs, SGMatrix< float64_t > local_gradients, SGMatrix< float64_t > weight_gradients, int32_t inputs_row_offset, int32_t local_gradients_row_offset)
 

Protected Attributes

int32_t m_input_width
 
int32_t m_input_height
 
int32_t m_radius_x
 
int32_t m_radius_y
 
int32_t m_stride_x
 
int32_t m_stride_y
 
int32_t m_index
 
EConvMapActivationFunction m_activation_function
 
int32_t m_output_width
 
int32_t m_output_height
 
int32_t m_input_num_neurons
 
int32_t m_output_num_neurons
 
int32_t m_row_offset
 
int32_t m_filter_width
 
int32_t m_filter_height
 
ENLAutoencoderPosition m_autoencoder_position
 

Constructor & Destructor Documentation

CConvolutionalFeatureMap ( int32_t  input_width,
int32_t  input_height,
int32_t  radius_x,
int32_t  radius_y,
int32_t  stride_x = 1,
int32_t  stride_y = 1,
int32_t  index = 0,
EConvMapActivationFunction  function = CMAF_IDENTITY,
ENLAutoencoderPosition  autoencoder_position = NLAP_NONE 
)

Constuctor

Parameters
input_widthWidth of the input
input_heightHeight of the input
radius_xRadius of the convolution filter on the x (width) axis
radius_yRadius of the convolution filter on the y (height) axis
stride_xStride in the x direction
stride_yStride in the y direction
indexIndex of this feature map in its layer. This affects which part of the activations/activation_gradients matrix the map will store its outputs in.
functionActivation function
autoencoder_positionAutoencoder position

Definition at line 43 of file ConvolutionalFeatureMap.cpp.

Member Function Documentation

void compute_activations ( SGVector< float64_t parameters,
CDynamicObjectArray layers,
SGVector< int32_t >  input_indices,
SGMatrix< float64_t activations 
)

Computes the activations of the feature map

Parameters
parametersVector of parameters for the map. length width*height+(2*radius_x+1)+(2*radius_y+1)
layersThe layers array that forms the network in which the map is being used
input_indicesIndices of the layers that are connected to the map as input
activationsMatrix in which the activations are to be stored

Definition at line 77 of file ConvolutionalFeatureMap.cpp.

void compute_gradients ( SGVector< float64_t parameters,
SGMatrix< float64_t activations,
SGMatrix< float64_t activation_gradients,
CDynamicObjectArray layers,
SGVector< int32_t >  input_indices,
SGVector< float64_t parameter_gradients 
)

Computes the gradients with respect to the parameters and the inputs to the map

Parameters
parametersVector of parameters for the map. length width*height+(2*radius_x+1)+(2*radius_y+1)
activationsActivations of the map
activation_gradientsGradients of the error with respect to the map's activations
layersThe layers array that forms the network in which the map is being used
input_indicesIndices of the layers that are connected to the map as input
parameter_gradientsVector in which the parameters gradients are to be stored

Definition at line 131 of file ConvolutionalFeatureMap.cpp.

void compute_weight_gradients ( SGMatrix< float64_t inputs,
SGMatrix< float64_t local_gradients,
SGMatrix< float64_t weight_gradients,
int32_t  inputs_row_offset,
int32_t  local_gradients_row_offset 
)
protected

Computes the gradients of the error with respect to the weights, for a particular input matrix

Parameters
inputsInputs matrix
local_gradientsGradients with respect the map's pre-activations
weight_gradientsMatrix to store the gradients in
inputs_row_offsetOffset for accessing the rows of the inputs matrix
local_gradients_row_offsetOffset for accessing the rows of the local gradients matrix

Definition at line 315 of file ConvolutionalFeatureMap.cpp.

void convolve ( SGMatrix< float64_t inputs,
SGMatrix< float64_t weights,
SGMatrix< float64_t outputs,
bool  flip,
bool  reset_output,
int32_t  inputs_row_offset,
int32_t  outputs_row_offset 
)
protected

Perfoms convolution

Parameters
inputsInputs matrix. Each column in the matrix is treated as an image in column major format
weightsConvolution filter
outputsOutput matrix
flipIf true the weights are flipped, performing cross-correlation instead of convolution
reset_outputtrue the output is reset to zero before performing convolution
inputs_row_offsetIndex of the row at which the input image starts
outputs_row_offsetIndex of the row at which the output image starts

Definition at line 267 of file ConvolutionalFeatureMap.cpp.

void pool_activations ( SGMatrix< float64_t activations,
int32_t  pooling_width,
int32_t  pooling_height,
SGMatrix< float64_t pooled_activations,
SGMatrix< float64_t max_indices 
)

Applies max pooling to the activations

Parameters
activationsActivations of the map
pooling_widthWidth of the pooling region
pooling_heightHeight of the pooling region
pooled_activationsResult of the pooling process
max_indicesRow indices of the max elements for each pooling region

Definition at line 197 of file ConvolutionalFeatureMap.cpp.

Member Data Documentation

EConvMapActivationFunction m_activation_function
protected

The map's activation function

Definition at line 199 of file ConvolutionalFeatureMap.h.

ENLAutoencoderPosition m_autoencoder_position
protected

For autoencoders, specifies the position of the layer in the autoencoder, i.e an encoding layer or a decoding layer. Default value is NLAP_NONE

Definition at line 225 of file ConvolutionalFeatureMap.h.

int32_t m_filter_height
protected

Height of the convolution filter

Definition at line 220 of file ConvolutionalFeatureMap.h.

int32_t m_filter_width
protected

Width of the convolution filter

Definition at line 217 of file ConvolutionalFeatureMap.h.

int32_t m_index
protected

Index of this feature map in its layer. This affects which part of the activations/activation_gradients matrix that map will use

Definition at line 196 of file ConvolutionalFeatureMap.h.

int32_t m_input_height
protected

Height of the input

Definition at line 179 of file ConvolutionalFeatureMap.h.

int32_t m_input_num_neurons
protected

Number of neurons in the input

Definition at line 208 of file ConvolutionalFeatureMap.h.

int32_t m_input_width
protected

Width of the input

Definition at line 176 of file ConvolutionalFeatureMap.h.

int32_t m_output_height
protected

Height of the convolution's output image

Definition at line 205 of file ConvolutionalFeatureMap.h.

int32_t m_output_num_neurons
protected

Number of neurons in the output

Definition at line 211 of file ConvolutionalFeatureMap.h.

int32_t m_output_width
protected

Width of the convolution's output image

Definition at line 202 of file ConvolutionalFeatureMap.h.

int32_t m_radius_x
protected

Radius of the convolution filter on the x (width) axis

Definition at line 182 of file ConvolutionalFeatureMap.h.

int32_t m_radius_y
protected

Radius of the convolution filter on the y (height) axis

Definition at line 185 of file ConvolutionalFeatureMap.h.

int32_t m_row_offset
protected

Row offset for accessing the activations

Definition at line 214 of file ConvolutionalFeatureMap.h.

int32_t m_stride_x
protected

Stride in the x direction

Definition at line 188 of file ConvolutionalFeatureMap.h.

int32_t m_stride_y
protected

Stride in the y direcetion

Definition at line 191 of file ConvolutionalFeatureMap.h.


The documentation for this class was generated from the following files:

SHOGUN Machine Learning Toolbox - Documentation