|
SHOGUN
3.2.1
|
Handles convolution and gradient calculation for a single feature map in a convolutional neural network.
Definition at line 64 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) | |
| void | compute_activations (SGVector< float64_t > parameters, CDynamicObjectArray *layers, SGVector< int32_t > input_indices, SGMatrix< float64_t > activations, SGMatrix< float64_t > buffer) |
| 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 |
| 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 |
||
| ) |
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 |
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, | ||
| SGMatrix< float64_t > | buffer | ||
| ) |
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 |
| buffer | Matrix of size (input_width*input_height)xbatch_size. Used as a buffer during computations |
Definition at line 67 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 134 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 295 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 250 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 203 of file ConvolutionalFeatureMap.cpp.
|
protected |
The map's activation function
Definition at line 235 of file ConvolutionalFeatureMap.h.
|
protected |
Height of the convolution filter
Definition at line 256 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the convolution filter
Definition at line 253 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 232 of file ConvolutionalFeatureMap.h.
|
protected |
Height of the input
Definition at line 215 of file ConvolutionalFeatureMap.h.
|
protected |
Number of neurons in the input
Definition at line 244 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the input
Definition at line 212 of file ConvolutionalFeatureMap.h.
|
protected |
Height of the convolution's output image
Definition at line 241 of file ConvolutionalFeatureMap.h.
|
protected |
Number of neurons in the output
Definition at line 247 of file ConvolutionalFeatureMap.h.
|
protected |
Width of the convolution's output image
Definition at line 238 of file ConvolutionalFeatureMap.h.
|
protected |
Radius of the convolution filter on the x (width) axis
Definition at line 218 of file ConvolutionalFeatureMap.h.
|
protected |
Radius of the convolution filter on the y (height) axis
Definition at line 221 of file ConvolutionalFeatureMap.h.
|
protected |
Row offset for accessing the activations
Definition at line 250 of file ConvolutionalFeatureMap.h.
|
protected |
Stride in the x direction
Definition at line 224 of file ConvolutionalFeatureMap.h.
|
protected |
Stride in the y direcetion
Definition at line 227 of file ConvolutionalFeatureMap.h.