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 
39  std::string LayerString(AdaptiveMaxPooling<> * /*layer*/) const
40  {
41  return "adaptivemaxpooling";
42  }
43 
50  std::string LayerString(AdaptiveMeanPooling<> * /*layer*/) const
51  {
52  return "adaptivemeanpooling";
53  }
54 
61  std::string LayerString(AtrousConvolution<>* /*layer*/) const
62  {
63  return "atrousconvolution";
64  }
65 
72  std::string LayerString(AlphaDropout<>* /*layer*/) const
73  {
74  return "alphadropout";
75  }
76 
83  std::string LayerString(BatchNorm<>* /*layer*/) const
84  {
85  return "batchnorm";
86  }
87 
94  std::string LayerString(Constant<>* /*layer*/) const
95  {
96  return "constant";
97  }
98 
105  std::string LayerString(Convolution<>* /*layer*/) const
106  {
107  return "convolution";
108  }
109 
116  std::string LayerString(DropConnect<>* /*layer*/) const
117  {
118  return "dropconnect";
119  }
120 
127  std::string LayerString(Dropout<>* /*layer*/) const
128  {
129  return "dropout";
130  }
131 
138  std::string LayerString(FlexibleReLU<>* /*layer*/) const
139  {
140  return "flexiblerelu";
141  }
142 
149  std::string LayerString(LayerNorm<>* /*layer*/) const
150  {
151  return "layernorm";
152  }
153 
160  std::string LayerString(Linear<>* /*layer*/) const
161  {
162  return "linear";
163  }
164 
171  std::string LayerString(LinearNoBias<>* /*layer*/) const
172  {
173  return "linearnobias";
174  }
175 
182  std::string LayerString(NoisyLinear<>* /*layer*/) const
183  {
184  return "noisylinear";
185  }
186 
193  std::string LayerString(MaxPooling<>* /*layer*/) const
194  {
195  return "maxpooling";
196  }
197 
204  std::string LayerString(MeanPooling<>* /*layer*/) const
205  {
206  return "meanpooling";
207  }
208 
215  std::string LayerString(MultiplyConstant<>* /*layer*/) const
216  {
217  return "multiplyconstant";
218  }
219 
226  std::string LayerString(ReLULayer<>* /*layer*/) const
227  {
228  return "relu";
229  }
230 
238  std::string LayerString(TransposedConvolution<>* /*layer*/) const
239  {
240  return "transposedconvolution";
241  }
242 
249  std::string LayerString(IdentityLayer<>* /*layer*/) const
250  {
251  return "identity";
252  }
253 
260  std::string LayerString(TanHLayer<>* /*layer*/) const
261  {
262  return "tanh";
263  }
264 
271  std::string LayerString(ELU<>* /*layer*/) const
272  {
273  return "elu";
274  }
275 
282  std::string LayerString(HardTanH<>* /*layer*/) const
283  {
284  return "hardtanh";
285  }
286 
293  std::string LayerString(LeakyReLU<>* /*layer*/) const
294  {
295  return "leakyrelu";
296  }
297 
304  std::string LayerString(PReLU<>* /*layer*/) const
305  {
306  return "prelu";
307  }
308 
315  std::string LayerString(SigmoidLayer<>* /*layer*/) const
316  {
317  return "sigmoid";
318  }
319 
326  std::string LayerString(LogSoftMax<>* /*layer*/) const
327  {
328  return "logsoftmax";
329  }
330 
331  /*
332  * Return the name of the given layer of type LSTM as a string.
333  *
334  * @param * Given layer of type LSTM.
335  * @return The string representation of the layer.
336  */
337  std::string LayerString(LSTM<>* /*layer*/) const
338  {
339  return "lstm";
340  }
341 
348  std::string LayerString(CReLU<>* /*layer*/) const
349  {
350  return "crelu";
351  }
352 
359  std::string LayerString(Highway<>* /*layer*/) const
360  {
361  return "highway";
362  }
363 
370  std::string LayerString(GRU<>* /*layer*/) const
371  {
372  return "gru";
373  }
374 
381  std::string LayerString(Glimpse<>* /*layer*/) const
382  {
383  return "glimpse";
384  }
385 
392  std::string LayerString(FastLSTM<>* /*layer*/) const
393  {
394  return "fastlstm";
395  }
396 
403  std::string LayerString(WeightNorm<>* /*layer*/) const
404  {
405  return "weightnorm";
406  }
407 
414  template<typename T>
415  std::string LayerString(T* /*layer*/) const
416  {
417  return "unsupported";
418  }
419 
421  std::string operator()(MoreTypes layer) const
422  {
423  return layer.apply_visitor(*this);
424  }
425 
427  template<typename LayerType>
428  std::string operator()(LayerType* layer) const
429  {
430  return LayerString(layer);
431  }
432 };
Artificial Neural Network.
std::string LayerString(LSTM<> *) const
Implementation of the AdaptiveMaxPooling layer.
std::string LayerString(Constant<> *) const
Return the name of the given layer of type Constant as a string.
Definition: layer_names.hpp:94
Implementation of the log softmax layer.
Definition: log_softmax.hpp:36
std::string LayerString(FastLSTM<> *) const
Return the name of the given layer of type FastLSTM as a string.
std::string LayerString(MultiplyConstant<> *) const
Return the name of the given layer of type MultiplyConstant as a string.
std::string LayerString(Dropout<> *) const
Return the name of the given layer of type Dropout as a string.
The FlexibleReLU activation function, defined by.
Implementation of the Transposed Convolution class.
std::string LayerString(Glimpse<> *) const
Return the name of the given layer of type Glimpse as a string.
Implementation of the Linear layer class.
Definition: layer_types.hpp:82
The LeakyReLU activation function, defined by.
Definition: leaky_relu.hpp:44
std::string LayerString(MaxPooling<> *) const
Return the name of the given layer of type MaxPooling as a string.
Implementation of the Convolution class.
Definition: convolution.hpp:48
Implementation of the MeanPooling.
std::string LayerString(ReLULayer<> *) const
Return the name of the given layer of type ReLULayer as a string.
std::string LayerString(TanHLayer<> *) const
Return the name of the given layer of type TanHLayer as a string.
std::string operator()(MoreTypes layer) const
Overload function call.
Declaration of the WeightNorm layer class.
std::string LayerString(IdentityLayer<> *) const
Return the name of the given layer of type IdentityLayer as a string.
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 AdaptiveMeanPooling.
Implementation of the base layer.
Definition: base_layer.hpp:65
std::string LayerString(LeakyReLU<> *) const
Return the name of the given layer of type LeakyReLU as a string.
std::string LayerString(WeightNorm<> *) const
Return the name of the given layer of type WeightNorm as a string.
std::string LayerString(CReLU<> *) const
Return the name of the given layer of type CReLU as a string.
std::string LayerString(LinearNoBias<> *) const
Return the name of the given layer of type LinearNoBias as a string.
std::string LayerString(Linear<> *) const
Return the name of the given layer of type Linear as a string.
Implementation of the Highway layer.
Definition: highway.hpp:60
std::string LayerString(AdaptiveMaxPooling<> *) const
Return the name of the given layer of type AdaptiveMaxPooling as string.
Definition: layer_names.hpp:39
Implementation of the LSTM module class.
Definition: layer_types.hpp:72
Declaration of the Layer Normalization class.
Definition: layer_norm.hpp:65
Implementation of the NoisyLinear layer class.
Definition: layer_types.hpp:96
std::string LayerString(Convolution<> *) const
Return the name of the given layer of type Convolution as a string.
boost::variant< Glimpse< arma::mat, arma::mat > *, Highway< arma::mat, arma::mat > *, 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 > *, RBF< arma::mat, arma::mat, GaussianFunction > *, BaseLayer< GaussianFunction, arma::mat, arma::mat > *> MoreTypes
Implementation of the LinearNoBias class.
Definition: layer_types.hpp:92
std::string LayerString(AdaptiveMeanPooling<> *) const
Return the name of the given layer of type AdaptiveMeanPooling as string.
Definition: layer_names.hpp:50
std::string LayerString(HardTanH<> *) const
Return the name of the given layer of type HardTanH as a string.
std::string LayerString(ELU<> *) const
Return the name of the given layer of type ELU as a string.
A concatenated ReLU has two outputs, one ReLU and one negative ReLU, concatenated together...
Definition: c_relu.hpp:50
std::string LayerString(AtrousConvolution<> *) const
Return the name of the given layer of type AtrousConvolution as a string.
Definition: layer_names.hpp:61
std::string LayerString(FlexibleReLU<> *) const
Return the name of the given layer of type FlexibleReLU as a string.
An implementation of a gru network layer.
Definition: gru.hpp:58
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:53
std::string LayerString(DropConnect<> *) const
Return the name of the given layer of type DropConnect as a string.
The glimpse layer returns a retina-like representation (down-scaled cropped images) of increasing sca...
Definition: glimpse.hpp:88
The DropConnect layer is a regularizer that randomly with probability ratio sets the connection value...
Definition: dropconnect.hpp:63
Implementation of the multiply constant layer.
std::string LayerString(AlphaDropout<> *) const
Return the name of the given layer of type AlphaDropout as a string.
Definition: layer_names.hpp:72
std::string LayerString(TransposedConvolution<> *) const
Return the name of the given layer of type TransposedConvolution as a string.
std::string LayerString(NoisyLinear<> *) const
Return the name of the given layer of type NoisyLinear as a string.
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
std::string LayerString(PReLU<> *) const
Return the name of the given layer of type PReLU as a string.
std::string LayerString(LogSoftMax<> *) const
Return the name of the given layer of type LogSoftMax as a string.
Declaration of the Batch Normalization layer class.
Definition: batch_norm.hpp:56
std::string LayerString(GRU<> *) const
Return the name of the given layer of type GRU as a string.
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
std::string LayerString(SigmoidLayer<> *) const
Return the name of the given layer of type SigmoidLayer as a string.
The ELU activation function, defined by.
Definition: elu.hpp:111
std::string LayerString(MeanPooling<> *) const
Return the name of the given layer of type MeanPooling as a string.
std::string LayerString(T *) const
Return the name of the layer of specified type as a string.
std::string operator()(LayerType *layer) const
Overload function call.
std::string LayerString(Highway<> *) const
Return the name of the given layer of type Highway as a string.
std::string LayerString(BatchNorm<> *) const
Return the name of the given layer of type BatchNorm as a string.
Definition: layer_names.hpp:83
An implementation of a faster version of the Fast LSTM network layer.
Definition: fast_lstm.hpp:66
std::string LayerString(LayerNorm<> *) const
Return the name of the given layer of type LayerNorm as a string.
Implementation of the Atrous Convolution class.