24enum KerasLayerTypes { K_UNKNOWN = 0, K_DENSE, K_LEAKY, K_DROPOUT, K_BN , K_ACTIVATION};
25enum KerasActivations { A_UNKNOWN = 0, A_LINEAR, A_SIGMOID , A_RELU, A_LEAKY, A_SOFTMAX};
39 int activation = A_UNKNOWN;
57 unordered_map<string, int> name_to_type = { {
"dense" , K_DENSE } ,{
"leaky", K_LEAKY } ,{
"dropout" , K_DROPOUT },{
"batch_normalization" , K_BN } , {
"activation", K_ACTIVATION} };
58 unordered_map<string, int> name_to_activation = { {
"linear" , A_LINEAR } ,{
"relu", A_RELU } ,{
"leaky" , A_LEAKY },{
"sigmoid" , A_SIGMOID }, {
"softmax", A_SOFTMAX} };
62 int apply_sparse(vector<pair<int, float>> &sline, vector<float> &output)
const;
63 int apply_sparse(map<int, float> &sline, vector<float> &output)
const;
64 int apply(vector<float> &in, vector<float> &out)
const;
65 int apply_bn(vector<float> &in, vector<float> &out)
const;
66 int apply_activation(vector<float> &in, vector<float> &out)
const;
74 int init(map<string, string>& _map);
77 ADD_SERIALIZATION_FUNCS(type, name, in_dim, out_dim, n_bias, activation, dim, drop_rate, leaky_alpha, wgts, twgts, bias)
85 vector<KerasLayer> layers;
87 int init_from_text_file(
string layers_file);
89 int apply_sparse(vector<pair<int, float>> &sline, vector<float> &output,
int to_layer)
const;
90 int apply_sparse(map<int, float> &sline, vector<float> &output,
int to_layer)
const;
91 int apply(vector<float>& line, vector<float> &output,
int to_layer)
const;
92 int apply(vector<float>& line, vector<float> &output)
const {
return apply(line, output, (
int)(layers.size() - 1)); }
98 int get_output_dimension() {
99 if (layers.size() > 0)
100 return layers.back().out_dim;
int init(map< string, string > &_map)
Virtual to init object from parsed fields.
Definition ApplyKeras.cpp:289