|
ATLAS Offline Software
|
Go to the documentation of this file.
16 std::vector<MatrixXd>&&
mm):
17 m_inputs(std::move(
vv)),
18 m_matrix_inputs(std::move(
mm))
37 const std::vector<std::pair<size_t,size_t> >&
ma):
48 VectorXd
vec(n_entries);
49 for (
size_t iii = 0; iii < n_entries; iii++) {
61 MatrixXd
mat(n_rows, n_cols);
62 for (
size_t iii = 0; iii < n_rows; iii++) {
63 for (
size_t jjj = 0; jjj < n_cols; jjj++) {
64 mat(iii, jjj) = jjj + n_cols * iii;
74 m_n_outputs(n_outputs)
84 "Found vector of length " + len +
", expected " +
found);
108 for (
const auto source: sources) {
117 size_t n_elements =
input.rows();
118 assert(n_elements ==
node->n_outputs());
132 m_n_outputs(n_outputs)
144 "Found vector of length " + len +
", expected " +
found);
163 size_t n_cols =
mat.cols();
168 return mat.col(n_cols - 1);
183 size_t n_columns =
input.cols();
184 for (
size_t col_n = 0; col_n < n_columns; col_n++) {
208 void throw_cfg(
const std::string &
msg,
size_t index) {
212 size_t n_source =
node.sources.size();
213 if (n_source != 1) throw_cfg(
"need one source, found", n_source);
214 int layer_n =
node.index;
215 if (layer_n < 0) throw_cfg(
"negative layer number", layer_n);
217 void check_compute_node(
const NodeConfig&
node,
size_t n_layers) {
218 check_compute_node(
node);
219 int layer_n =
node.index;
220 if (
static_cast<size_t>(layer_n) >= n_layers) {
221 throw_cfg(
"no layer number", layer_n);
225 INode* get_feedforward_node(
227 const std::vector<LayerConfig>&
layers,
228 const std::unordered_map<size_t, INode*>& node_map,
229 std::unordered_map<size_t, Stack*>& stack_map) {
234 int layer_n =
node.index;
235 if (!stack_map.count(layer_n)) {
236 stack_map[layer_n] =
new Stack(
source->n_outputs(),
237 {layers.at(layer_n)});
243 const std::vector<LayerConfig>&
layers,
244 const std::unordered_map<size_t, ISequenceNode*>& node_map,
245 std::unordered_map<size_t, RecurrentStack*>& stack_map) {
249 int layer_n =
node.index;
250 if (!stack_map.count(layer_n)) {
252 {layers.at(layer_n)});
258 const std::vector<LayerConfig>&
layers,
259 const std::unordered_map<size_t, ISequenceNode*>& node_map,
260 std::unordered_map<size_t, Stack*>& stack_map) {
265 int layer_n =
node.index;
266 if (!stack_map.count(layer_n)) {
267 stack_map[layer_n] =
new Stack(
source->n_outputs(),
268 {layers.at(layer_n)});
286 const std::vector<LayerConfig>&
layers):
289 for (
size_t iii = 0; iii < nodes.size(); iii++) {
297 node.second =
nullptr;
304 node.second =
nullptr;
308 stack.second =
nullptr;
312 stack.second =
nullptr;
316 if (!
m_nodes.count(node_number)) {
320 "Graph: output at " +
num +
" not feed forward");
335 if (
m_nodes.count(node_number)) {
337 "Graph: output at " +
num +
" not a sequence");
354 const std::vector<NodeConfig>& nodes,
355 const std::vector<LayerConfig>&
layers,
356 std::set<size_t> cycle_check) {
364 if (iii >= nodes.size()) throw_cfg(
"no node index", iii);
370 check_compute_node(
node);
371 size_t input_number =
node.sources.at(0);
375 check_compute_node(
node);
376 size_t input_number =
node.sources.at(0);
382 if (cycle_check.count(iii)) {
385 cycle_check.insert(iii);
386 for (
size_t source_node:
node.sources) {
398 std::unique_ptr<SequenceNode> seq_node(
403 m_nodes[iii] = seq_node.release();
406 std::vector<const INode*> in_nodes;
407 for (
size_t source_node:
node.sources) {
408 in_nodes.push_back(
m_nodes.at(source_node));
412 if (
node.sources.size() != 1) {
FeedForwardNode(const Stack *, const INode *source)
virtual size_t n_outputs() const override
virtual VectorXd at(size_t index) const override
virtual size_t n_outputs() const override
DummySource(const std::vector< size_t > &input_sizes, const std::vector< std::pair< size_t, size_t > > &={})
MatrixXd scan(MatrixXd inputs) const
const ISequenceNode * m_source
std::vector< std::pair< size_t, size_t > > m_matrix_sizes
std::unordered_map< size_t, INode * > m_nodes
virtual VectorXd compute(const ISource &) const override
virtual VectorXd compute(const ISource &) const override
virtual VectorXd at(size_t index) const override
void build_node(const size_t, const std::vector< NodeConfig > &nodes, const std::vector< LayerConfig > &layers, std::set< size_t > cycle_check={})
virtual MatrixXd matrix_at(size_t index) const override
SequenceNode(const RecurrentStack *, const ISequenceNode *source)
SumNode(const ISequenceNode *source)
const ISequenceNode * m_source
virtual VectorXd compute(const ISource &) const override
std::unordered_map< size_t, Stack * > m_stacks
typename vecDetail::vec_typedef< T, N >::type vec
Define a nice alias for the vectorized type.
virtual size_t n_outputs() const override
std::vector< MatrixXd > m_matrix_inputs
VectorSource(std::vector< VectorXd > &&, std::vector< MatrixXd > &&={})
virtual MatrixXd scan(const ISource &) const =0
std::vector< const INode * > m_sources
const ISequenceNode * m_source
virtual VectorXd compute(const ISource &) const =0
virtual MatrixXd scan(const ISource &) const override
TimeDistributedNode(const Stack *, const ISequenceNode *source)
ConcatenateNode(const std::vector< const INode * > &)
virtual MatrixXd scan(const ISource &) const override
std::string to_string(const DetectorType &type)
std::unordered_map< size_t, ISequenceNode * > m_seq_nodes
const RecurrentStack * m_stack
std::vector< VectorXd > m_inputs
std::vector< size_t > m_sizes
VectorXd compute(const ISource &, size_t node_number) const
virtual size_t n_outputs() const override
MatrixXd scan(const ISource &, size_t node_number) const
virtual size_t n_outputs() const =0
virtual VectorXd compute(const ISource &) const override
VectorXd compute(VectorXd) const
std::unordered_map< size_t, RecurrentStack * > m_seq_stacks
virtual size_t n_outputs() const override
virtual MatrixXd matrix_at(size_t index) const override