SHOGUN
4.2.0
|
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 |
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
input_width | Width of the input |
input_height | Height of the input |
radius_x | Radius of the convolution filter on the x (width) axis |
radius_y | Radius of the convolution filter on the y (height) axis |
stride_x | Stride in the x direction |
stride_y | Stride in the y direction |
index | Index of this feature map in its layer. This affects which part of the activations/activation_gradients matrix the map will store its outputs in. |
function | Activation function |
autoencoder_position | Autoencoder position |
Definition at line 43 of file ConvolutionalFeatureMap.cpp.
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 | Vector of parameters for the map. length width*height+(2*radius_x+1)+(2*radius_y+1) |
layers | The layers array that forms the network in which the map is being used |
input_indices | Indices of the layers that are connected to the map as input |
activations | Matrix 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 | Vector of parameters for the map. length width*height+(2*radius_x+1)+(2*radius_y+1) |
activations | Activations of the map |
activation_gradients | Gradients of the error with respect to the map's activations |
layers | The layers array that forms the network in which the map is being used |
input_indices | Indices of the layers that are connected to the map as input |
parameter_gradients | Vector in which the parameters gradients are to be stored |
Definition at line 131 of file ConvolutionalFeatureMap.cpp.
|
protected |
Computes the gradients of the error with respect to the weights, for a particular input matrix
inputs | Inputs matrix |
local_gradients | Gradients with respect the map's pre-activations |
weight_gradients | Matrix to store the gradients in |
inputs_row_offset | Offset for accessing the rows of the inputs matrix |
local_gradients_row_offset | Offset for accessing the rows of the local gradients matrix |
Definition at line 315 of file ConvolutionalFeatureMap.cpp.
|
protected |
Perfoms convolution
inputs | Inputs matrix. Each column in the matrix is treated as an image in column major format |
weights | Convolution filter |
outputs | Output matrix |
flip | If true the weights are flipped, performing cross-correlation instead of convolution |
reset_output | true the output is reset to zero before performing convolution |
inputs_row_offset | Index of the row at which the input image starts |
outputs_row_offset | Index 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
activations | Activations of the map |
pooling_width | Width of the pooling region |
pooling_height | Height of the pooling region |
pooled_activations | Result of the pooling process |
max_indices | Row indices of the max elements for each pooling region |
Definition at line 197 of file ConvolutionalFeatureMap.cpp.
|
protected |
The map's activation function
Definition at line 199 of file ConvolutionalFeatureMap.h.
|
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.
|
protected |
Height of the convolution filter
Definition at line 220 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the convolution filter
Definition at line 217 of file ConvolutionalFeatureMap.h.
|
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.
|
protected |
Height of the input
Definition at line 179 of file ConvolutionalFeatureMap.h.
|
protected |
Number of neurons in the input
Definition at line 208 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the input
Definition at line 176 of file ConvolutionalFeatureMap.h.
|
protected |
Height of the convolution's output image
Definition at line 205 of file ConvolutionalFeatureMap.h.
|
protected |
Number of neurons in the output
Definition at line 211 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the convolution's output image
Definition at line 202 of file ConvolutionalFeatureMap.h.
|
protected |
Radius of the convolution filter on the x (width) axis
Definition at line 182 of file ConvolutionalFeatureMap.h.
|
protected |
Radius of the convolution filter on the y (height) axis
Definition at line 185 of file ConvolutionalFeatureMap.h.
|
protected |
Row offset for accessing the activations
Definition at line 214 of file ConvolutionalFeatureMap.h.
|
protected |
Stride in the x direction
Definition at line 188 of file ConvolutionalFeatureMap.h.
|
protected |
Stride in the y direcetion
Definition at line 191 of file ConvolutionalFeatureMap.h.