1 #ifndef UTILS_ENUM_H_
2 #define UTILS_ENUM_H_
3 
4 #include <string>
5 #include <stdexcept>
6 #include "../Config.h"
7 
8 namespace MiniDNN
9 {
10 
11 namespace internal
12 {
13 
14 
15 // Enumerations for hidden layers
16 enum LAYER_ENUM
17 {
18     FULLY_CONNECTED = 0,
19     CONVOLUTIONAL,
20     MAX_POOLING
21 };
22 
23 // Convert a hidden layer type string to an integer
layer_id(const std::string & type)24 inline int layer_id(const std::string& type)
25 {
26     if (type == "FullyConnected")
27         return FULLY_CONNECTED;
28     if (type == "Convolutional")
29         return CONVOLUTIONAL;
30     if (type == "MaxPooling")
31         return MAX_POOLING;
32 
33     throw std::invalid_argument("[function layer_id]: Layer is not of a known type");
34     return -1;
35 }
36 
37 // Enumerations for activation functions
38 enum ACTIVATION_ENUM
39 {
40     IDENTITY = 0,
41     RELU,
42     SIGMOID,
43     SOFTMAX,
44     TANH,
45     MISH
46 };
47 
48 // Convert an activation type string to an integer
activation_id(const std::string & type)49 inline int activation_id(const std::string& type)
50 {
51     if (type == "Identity")
52         return IDENTITY;
53     if (type == "ReLU")
54         return RELU;
55     if (type == "Sigmoid")
56         return SIGMOID;
57     if (type == "Softmax")
58         return SOFTMAX;
59     if (type == "Tanh")
60         return TANH;
61     if (type == "Mish")
62         return MISH;
63 
64     throw std::invalid_argument("[function activation_id]: Activation is not of a known type");
65     return -1;
66 }
67 
68 // Enumerations for output layers
69 enum OUTPUT_ENUM
70 {
71     REGRESSION_MSE = 0,
72     BINARY_CLASS_ENTROPY,
73     MULTI_CLASS_ENTROPY
74 };
75 
76 // Convert an output layer type string to an integer
output_id(const std::string & type)77 inline int output_id(const std::string& type)
78 {
79     if (type == "RegressionMSE")
80         return REGRESSION_MSE;
81     if (type == "MultiClassEntropy")
82         return BINARY_CLASS_ENTROPY;
83     if (type == "BinaryClassEntropy")
84         return MULTI_CLASS_ENTROPY;
85 
86     throw std::invalid_argument("[function output_id]: Output is not of a known type");
87     return -1;
88 }
89 
90 
91 } // namespace internal
92 
93 } // namespace MiniDNN
94 
95 
96 #endif /* UTILS_ENUM_H_ */
97