SHOGUN  4.1.0
 全部  命名空间 文件 函数 变量 类型定义 枚举 枚举值 友元 宏定义  
ConvolutionalFeatureMap.h
浏览该文件的文档.
1 /*
2  * Copyright (c) 2014, Shogun Toolbox Foundation
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  *
8  * 1. Redistributions of source code must retain the above copyright notice,
9  * this list of conditions and the following disclaimer.
10  *
11  * 2. Redistributions in binary form must reproduce the above copyright notice,
12  * this list of conditions and the following disclaimer in the documentation
13  * and/or other materials provided with the distribution.
14  *
15  * 3. Neither the name of the copyright holder nor the names of its
16  * contributors may be used to endorse or promote products derived from this
17  * software without specific prior written permission.
18  *
19  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
20  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22  * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
23  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29  * POSSIBILITY OF SUCH DAMAGE.
30  *
31  * Written (W) 2014 Khaled Nasr
32  */
33 
34 #ifndef __CONVOLUTIONALFEATUREMAP_H__
35 #define __CONVOLUTIONALFEATUREMAP_H__
36 
37 #include <shogun/lib/common.h>
39 
40 namespace shogun
41 {
42 
47 {
50 
53 
56 };
57 
58 template <class T> class SGVector;
59 template <class T> class SGMatrix;
60 class CDynamicObjectArray;
61 
66 {
67 public:
82  CConvolutionalFeatureMap(int32_t input_width, int32_t input_height,
83  int32_t radius_x, int32_t radius_y,
84  int32_t stride_x=1, int32_t stride_y=1,
85  int32_t index=0,
87  ENLAutoencoderPosition autoencoder_position = NLAP_NONE);
88 
100  CDynamicObjectArray* layers,
101  SGVector<int32_t> input_indices,
102  SGMatrix<float64_t> activations);
103 
116  void compute_gradients(SGVector<float64_t> parameters,
117  SGMatrix<float64_t> activations,
118  SGMatrix<float64_t> activation_gradients,
119  CDynamicObjectArray* layers,
120  SGVector<int32_t> input_indices,
121  SGVector<float64_t> parameter_gradients);
122 
131  void pool_activations(SGMatrix<float64_t> activations,
132  int32_t pooling_width,
133  int32_t pooling_height,
134  SGMatrix<float64_t> pooled_activations,
135  SGMatrix<float64_t> max_indices);
136 
137 protected:
151  void convolve(SGMatrix<float64_t> inputs,
152  SGMatrix<float64_t> weights,
153  SGMatrix<float64_t> outputs,
154  bool flip,
155  bool reset_output,
156  int32_t inputs_row_offset,
157  int32_t outputs_row_offset);
158 
169  SGMatrix<float64_t> local_gradients,
170  SGMatrix<float64_t> weight_gradients,
171  int32_t inputs_row_offset,
172  int32_t local_gradients_row_offset);
173 
174 protected:
176  int32_t m_input_width;
177 
179  int32_t m_input_height;
180 
182  int32_t m_radius_x;
183 
185  int32_t m_radius_y;
186 
188  int32_t m_stride_x;
189 
191  int32_t m_stride_y;
192 
196  int32_t m_index;
197 
200 
202  int32_t m_output_width;
203 
206 
209 
212 
214  int32_t m_row_offset;
215 
217  int32_t m_filter_width;
218 
221 
226 };
227 
228 }
229 #endif
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)
ENLAutoencoderPosition m_autoencoder_position
EConvMapActivationFunction m_activation_function
Handles convolution and gradient calculation for a single feature map in a convolutional neural netwo...
ENLAutoencoderPosition
Definition: NeuralLayer.h:49
void compute_activations(SGVector< float64_t > parameters, CDynamicObjectArray *layers, SGVector< int32_t > input_indices, SGMatrix< float64_t > activations)
Dynamic array class for CSGObject pointers that creates an array that can be used like a list or an a...
all of classes and functions are contained in the shogun namespace
Definition: class_list.h:18
EConvMapActivationFunction
Determines the activation function for neurons in a convolutional feature map.
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 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)
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)
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)

SHOGUN 机器学习工具包 - 项目文档