mlpack  3.1.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
layer_names.hpp
Go to the documentation of this file.
1 
13 #include <mlpack/core.hpp>
16 #include <boost/variant/static_visitor.hpp>
17 #include <string>
18 
19 using namespace mlpack::ann;
20 
25 class LayerNameVisitor : public boost::static_visitor<std::string>
26 {
27  public:
30  {
31  }
32 
33  /*
34  * Return the name of the given layer of type AtrousConvolution as a string.
35  *
36  * @param Given layer of type AtrousConvolution.
37  * @return The string representation of the layer.
38  */
39  std::string LayerString(AtrousConvolution<>* /*layer*/) const
40  {
41  return "atrousconvolution";
42  }
43 
44  /*
45  * Return the name of the given layer of type AlphaDropout as a string.
46  *
47  * @param Given layer of type AlphaDropout.
48  * @return The string representation of the layer.
49  */
50  std::string LayerString(AlphaDropout<>* /*layer*/) const
51  {
52  return "alphadropout";
53  }
54 
55  /*
56  * Return the name of the given layer of type BatchNorm as a string.
57  *
58  * @param Given layer of type BatchNorm.
59  * @return The string representation of the layer.
60  */
61  std::string LayerString(BatchNorm<>* /*layer*/) const
62  {
63  return "batchnorm";
64  }
65 
66  /*
67  * Return the name of the given layer of type Constant as a string.
68  *
69  * @param Given layer of type Constant.
70  * @return The string representation of the layer.
71  */
72  std::string LayerString(Constant<>* /*layer*/) const
73  {
74  return "constant";
75  }
76 
77  /*
78  * Return the name of the given layer of type Convolution as a string.
79  *
80  * @param Given layer of type Convolution.
81  * @return The string representation of the layer.
82  */
83  std::string LayerString(Convolution<>* /*layer*/) const
84  {
85  return "convolution";
86  }
87 
88  /*
89  * Return the name of the given layer of type DropConnect as a string.
90  *
91  * @param Given layer of type DropConnect.
92  * @return The string representation of the layer.
93  */
94  std::string LayerString(DropConnect<>* /*layer*/) const
95  {
96  return "dropconnect";
97  }
98 
99  /*
100  * Return the name of the given layer of type Dropout as a string.
101  *
102  * @param Given layer of type Dropout.
103  * @return The string representation of the layer.
104  */
105  std::string LayerString(Dropout<>* /*layer*/) const
106  {
107  return "dropout";
108  }
109 
110  /*
111  * Return the name of the given layer of type FlexibleReLU as a string.
112  *
113  * @param Given layer of type FlexibleReLU.
114  * @return The string representation of the layer.
115  */
116  std::string LayerString(FlexibleReLU<>* /*layer*/) const
117  {
118  return "flexiblerelu";
119  }
120 
121  /*
122  * Return the name of the given layer of type LayerNorm as a string.
123  *
124  * @param Given layer of type LayerNorm.
125  * @return The string representation of the layer.
126  */
127  std::string LayerString(LayerNorm<>* /*layer*/) const
128  {
129  return "layernorm";
130  }
131 
132  /*
133  * Return the name of the given layer of type Linear as a string.
134  *
135  * @param Given layer of type Linear.
136  * @return The string representation of the layer.
137  */
138  std::string LayerString(Linear<>* /*layer*/) const
139  {
140  return "linear";
141  }
142 
143  /*
144  * Return the name of the given layer of type LinearNoBias as a string.
145  *
146  * @param Given layer of type LinearNoBias.
147  * @return The string representation of the layer.
148  */
149  std::string LayerString(LinearNoBias<>* /*layer*/) const
150  {
151  return "linearnobias";
152  }
153 
154  /*
155  * Return the name of the given layer of type MaxPooling as a string.
156  *
157  * @param Given layer of type MaxPooling.
158  * @return The string representation of the layer.
159  */
160  std::string LayerString(MaxPooling<>* /*layer*/) const
161  {
162  return "maxpooling";
163  }
164 
165  /*
166  * Return the name of the given layer of type MeanPooling as a string.
167  *
168  * @param Given layer of type MeanPooling.
169  * @return The string representation of the layer.
170  */
171  std::string LayerString(MeanPooling<>* /*layer*/) const
172  {
173  return "meanpooling";
174  }
175 
176  /*
177  * Return the name of the given layer of type MultiplyConstant as a string.
178  *
179  * @param Given layer of type MultiplyConstant.
180  * @return The string representation of the layer.
181  */
182  std::string LayerString(MultiplyConstant<>* /*layer*/) const
183  {
184  return "multiplyconstant";
185  }
186 
187  /*
188  * Return the name of the given layer of type ReLULayer as a string.
189  *
190  * @param Given layer of type ReLULayer.
191  * @return The string representation of the layer.
192  */
193  std::string LayerString(ReLULayer<>* /*layer*/) const
194  {
195  return "relu";
196  }
197 
198  /*
199  * Return the name of the given layer of type TransposedConvolution as a
200  * string.
201  *
202  * @param Given layer of type TransposedConvolution.
203  * @return The string representation of the layer.
204  */
205  std::string LayerString(TransposedConvolution<>* /*layer*/) const
206  {
207  return "transposedconvolution";
208  }
209 
210  /*
211  * Return the name of the given layer of type IdentityLayer as a string.
212  *
213  * @param Given layer of type IdentityLayer.
214  * @return The string representation of the layer.
215  */
216  std::string LayerString(IdentityLayer<>* /*layer*/) const
217  {
218  return "identity";
219  }
220 
221  /*
222  * Return the name of the given layer of type TanHLayer as a string.
223  *
224  * @param Given layer of type TanHLayer.
225  * @return The string representation of the layer.
226  */
227  std::string LayerString(TanHLayer<>* /*layer*/) const
228  {
229  return "tanh";
230  }
231 
232  /*
233  * Return the name of the given layer of type ELU as a string.
234  *
235  * @param Given layer of type ELU.
236  * @return The string representation of the layer.
237  */
238  std::string LayerString(ELU<>* /*layer*/) const
239  {
240  return "elu";
241  }
242 
243  /*
244  * Return the name of the given layer of type HardTanH as a string.
245  *
246  * @param Given layer of type HardTanH.
247  * @return The string representation of the layer.
248  */
249  std::string LayerString(HardTanH<>* /*layer*/) const
250  {
251  return "hardtanh";
252  }
253 
254  /*
255  * Return the name of the given layer of type LeakyReLU as a string.
256  *
257  * @param Given layer of type LeakyReLU.
258  * @return The string representation of the layer.
259  */
260  std::string LayerString(LeakyReLU<>* /*layer*/) const
261  {
262  return "leakyrelu";
263  }
264 
265  /*
266  * Return the name of the given layer of type PReLU as a string.
267  *
268  * @param Given layer of type PReLU.
269  * @return The string representation of the layer.
270  */
271  std::string LayerString(PReLU<>* /*layer*/) const
272  {
273  return "prelu";
274  }
275 
276  /*
277  * Return the name of the given layer of type SigmoidLayer as a string.
278  *
279  * @param Given layer of type SigmoidLayer.
280  * @return The string representation of the layer.
281  */
282  std::string LayerString(SigmoidLayer<>* /*layer*/) const
283  {
284  return "sigmoid";
285  }
286 
287  /*
288  * Return the name of the given layer of type LogSoftMax as a string.
289  *
290  * @param Given layer of type LogSoftMax.
291  * @return The string representation of the layer.
292  */
293  std::string LayerString(LogSoftMax<>* /*layer*/) const
294  {
295  return "logsoftmax";
296  }
297 
298  /*
299  * Return the name of the layer of specified type as a string.
300  *
301  * @param Given layer of any type.
302  * @return A string declaring that the layer is unsupported.
303  */
304  template<typename T>
305  std::string LayerString(T* /*layer*/) const
306  {
307  return "unsupported";
308  }
309 
311  std::string operator()(MoreTypes layer) const
312  {
313  return layer.apply_visitor(*this);
314  }
315 
317  template<typename LayerType>
318  std::string operator()(LayerType* layer) const
319  {
320  return LayerString(layer);
321  }
322 };
boost::variant< Recurrent< arma::mat, arma::mat > *, RecurrentAttention< arma::mat, arma::mat > *, ReinforceNormal< arma::mat, arma::mat > *, Reparametrization< arma::mat, arma::mat > *, Select< arma::mat, arma::mat > *, Sequential< arma::mat, arma::mat, false > *, Sequential< arma::mat, arma::mat, true > *, Subview< arma::mat, arma::mat > *, VRClassReward< arma::mat, arma::mat > *, VirtualBatchNorm< arma::mat, arma::mat > * > MoreTypes
std::string LayerString(Constant<> *) const
Definition: layer_names.hpp:72
Implementation of the log softmax layer.
Definition: log_softmax.hpp:36
std::string LayerString(AlphaDropout<> *) const
Definition: layer_names.hpp:50
std::string LayerString(SigmoidLayer<> *) const
std::string operator()(LayerType *layer) const
Overload function call.
std::string LayerString(LinearNoBias<> *) const
std::string LayerString(Dropout<> *) const
std::string LayerString(MeanPooling<> *) const
The FlexibleReLU activation function, defined by.
Implementation of the Transposed Convolution class.
std::string LayerString(LayerNorm<> *) const
std::string LayerString(BatchNorm<> *) const
Definition: layer_names.hpp:61
std::string LayerString(ReLULayer<> *) const
Implementation of the Linear layer class.
Definition: layer_types.hpp:73
The LeakyReLU activation function, defined by.
Definition: leaky_relu.hpp:44
std::string LayerString(HardTanH<> *) const
std::string LayerString(MultiplyConstant<> *) const
std::string LayerString(FlexibleReLU<> *) const
Implementation of the Convolution class.
Definition: convolution.hpp:47
Implementation of the MeanPooling.
std::string LayerString(TransposedConvolution<> *) const
std::string LayerString(AtrousConvolution<> *) const
Definition: layer_names.hpp:39
The Hard Tanh activation function, defined by.
Definition: hard_tanh.hpp:49
The PReLU activation function, defined by (where alpha is trainable)
Implementation of the base layer.
Definition: base_layer.hpp:49
std::string LayerString(LogSoftMax<> *) const
std::string operator()(MoreTypes layer) const
Overload function call.
std::string LayerString(ELU<> *) const
Declaration of the Layer Normalization class.
Definition: layer_norm.hpp:65
Implementation of the LinearNoBias class.
Definition: layer_types.hpp:78
std::string LayerString(TanHLayer<> *) const
std::string LayerString(Convolution<> *) const
Definition: layer_names.hpp:83
Include all of the base components required to write mlpack methods, and the main mlpack Doxygen docu...
The dropout layer is a regularizer that randomly with probability &#39;ratio&#39; sets input values to zero a...
Definition: dropout.hpp:52
std::string LayerString(MaxPooling<> *) const
std::string LayerString(IdentityLayer<> *) const
std::string LayerString(T *) const
The DropConnect layer is a regularizer that randomly with probability ratio sets the connection value...
Definition: dropconnect.hpp:62
Implementation of the multiply constant layer.
The alpha - dropout layer is a regularizer that randomly with probability &#39;ratio&#39; sets input values t...
Implementation of a class that returns the string representation of the name of the given layer...
Definition: layer_names.hpp:25
Declaration of the Batch Normalization layer class.
Definition: batch_norm.hpp:56
LayerNameVisitor()
Create the LayerNameVisitor object.
Definition: layer_names.hpp:29
Implementation of the constant layer.
Definition: constant.hpp:34
Implementation of the MaxPooling layer.
Definition: max_pooling.hpp:52
The ELU activation function, defined by.
Definition: elu.hpp:109
std::string LayerString(LeakyReLU<> *) const
std::string LayerString(PReLU<> *) const
std::string LayerString(DropConnect<> *) const
Definition: layer_names.hpp:94
std::string LayerString(Linear<> *) const
Implementation of the Atrous Convolution class.