ATLAS Offline Software
NNLayerConfig.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef NN_LAYER_CONFIG_HH_TAURECTOOLS
6 #define NN_LAYER_CONFIG_HH_TAURECTOOLS
7 
8 // Layer Configiruation for Lightweight Tagger
9 //
10 // The structures below are used to initalize
11 // `LightweightNeuralNetwork` and the simpler `Stack`.
12 //
13 // Author: Dan Guest <dguest@cern.ch>
14 
15 #include <vector>
16 #include <map>
17 #include <string>
18 
19 namespace lwtDev {
24  // components (for LSTM, etc)
25  enum class Component {
26  I, O, C, F, // LSTM
27  Z, R, H, // GRU
28  T, CARRY}; // Highway
29 
30  // structure for embedding layers
32  {
33  std::vector<double> weights;
34  int index;
35  int n_out;
36  };
37 
39  {
41  double alpha = 0;
42  };
43 
44  // main layer configuration
45  struct LayerConfig
46  {
47  // dense layer info
48  std::vector<double> weights;
49  std::vector<double> bias;
50  std::vector<double> U; // TODO: what is this thing called in LSTMs?
52  ActivationConfig inner_activation; // for LSTMs and GRUs
53  bool go_backwards = false; // for LSTMs and GRUs
54  bool return_sequence = false; // for LSTMs and GRUs
55  std::string merge_mode; // for Bidirectional
56 
57 
58  // additional info for sublayers
59  std::vector<LayerConfig> sublayers;
60  std::map<Component, LayerConfig> components;
61  std::vector<EmbeddingConfig> embedding;
62 
63  // arch flag
65  };
66 
67  // graph node configuration
68  struct NodeConfig
69  {
70  enum class Type {
74  std::vector<size_t> sources;
75  int index; // input node size, or layer number
76  };
77 }
78 
79 #endif
lwtDev::Architecture::DENSE
@ DENSE
lwtDev::Component::C
@ C
lwtDev::Activation::LINEAR
@ LINEAR
lwtDev::Component::Z
@ Z
lwtDev::LayerConfig::embedding
std::vector< EmbeddingConfig > embedding
Definition: NNLayerConfig.h:61
lwtDev::Activation::RECTIFIED
@ RECTIFIED
lwtDev::ActivationConfig::alpha
double alpha
Definition: NNLayerConfig.h:41
lwtDev::Activation::LEAKY_RELU
@ LEAKY_RELU
lwtDev::Architecture
Architecture
Definition: NNLayerConfig.h:22
lwtDev::NodeConfig::Type::INPUT_SEQUENCE
@ INPUT_SEQUENCE
lwtDev::LayerConfig::U
std::vector< double > U
Definition: NNLayerConfig.h:50
lwtDev::NodeConfig::Type::SUM
@ SUM
lwtDev::Architecture::LSTM
@ LSTM
lwtDev::LayerConfig::inner_activation
ActivationConfig inner_activation
Definition: NNLayerConfig.h:52
lwtDev::NodeConfig::Type::SEQUENCE
@ SEQUENCE
lwtDev::LayerConfig::architecture
Architecture architecture
Definition: NNLayerConfig.h:64
lwtDev::Component::I
@ I
lwtDev::Activation::TANH
@ TANH
lwtDev::Activation::NONE
@ NONE
lwtDev::LayerConfig
Definition: NNLayerConfig.h:46
lwtDev::NodeConfig::Type::CONCATENATE
@ CONCATENATE
lwtDev::Component::O
@ O
lwtDev::EmbeddingConfig
Definition: NNLayerConfig.h:32
lwtDev::NodeConfig::Type::TIME_DISTRIBUTED
@ TIME_DISTRIBUTED
lwtDev::Activation::SWISH
@ SWISH
lwtDev::EmbeddingConfig::n_out
int n_out
Definition: NNLayerConfig.h:35
lwtDev::Activation::ELU
@ ELU
lwtDev::Component::F
@ F
lwtDev::NodeConfig::Type::INPUT
@ INPUT
xAODType
Definition: ObjectType.h:13
lwtDev::LayerConfig::merge_mode
std::string merge_mode
Definition: NNLayerConfig.h:55
lwtDev::Architecture::NONE
@ NONE
lwtDev::Architecture::MAXOUT
@ MAXOUT
lwtDev::Architecture::HIGHWAY
@ HIGHWAY
lwtDev::Activation::ABS
@ ABS
lwtDev
Definition: Reconstruction/tauRecTools/Root/lwtnn/Exceptions.cxx:8
lwtDev::Component::T
@ T
lwtDev::NodeConfig::type
Type type
Definition: NNLayerConfig.h:73
lwtDev::ActivationConfig
Definition: NNLayerConfig.h:39
lwtDev::LayerConfig::weights
std::vector< double > weights
Definition: NNLayerConfig.h:48
lwtDev::LayerConfig::go_backwards
bool go_backwards
Definition: NNLayerConfig.h:53
lwtDev::LayerConfig::components
std::map< Component, LayerConfig > components
Definition: NNLayerConfig.h:60
lwtDev::NodeConfig::index
int index
Definition: NNLayerConfig.h:75
lwtDev::Architecture::GRU
@ GRU
lwtDev::Architecture::BIDIRECTIONAL
@ BIDIRECTIONAL
lwtDev::Activation::HARD_SIGMOID
@ HARD_SIGMOID
lwtDev::Component
Component
Definition: NNLayerConfig.h:25
lwtDev::EmbeddingConfig::weights
std::vector< double > weights
Definition: NNLayerConfig.h:33
lwtDev::LayerConfig::return_sequence
bool return_sequence
Definition: NNLayerConfig.h:54
lwtDev::Activation::SIGMOID
@ SIGMOID
lwtDev::LayerConfig::bias
std::vector< double > bias
Definition: NNLayerConfig.h:49
lwtDev::Architecture::EMBEDDING
@ EMBEDDING
lwtDev::NodeConfig::Type::FEED_FORWARD
@ FEED_FORWARD
lwtDev::Component::CARRY
@ CARRY
lwtDev::NodeConfig::sources
std::vector< size_t > sources
Definition: NNLayerConfig.h:74
lwtDev::Architecture::NORMALIZATION
@ NORMALIZATION
lwtDev::Component::R
@ R
lwtDev::Activation
Activation
Definition: NNLayerConfig.h:20
lwtDev::LayerConfig::activation
ActivationConfig activation
Definition: NNLayerConfig.h:51
lwtDev::NodeConfig
Definition: NNLayerConfig.h:69
lwtDev::EmbeddingConfig::index
int index
Definition: NNLayerConfig.h:34
lwtDev::LayerConfig::sublayers
std::vector< LayerConfig > sublayers
Definition: NNLayerConfig.h:59
lwtDev::Component::H
@ H
lwtDev::Activation::SOFTMAX
@ SOFTMAX