ATLAS Offline Software
Loading...
Searching...
No Matches
lwt::atlas::FastInputVectorPreprocessor Class Reference

#include <FastInputPreprocessor.h>

Collaboration diagram for lwt::atlas::FastInputVectorPreprocessor:

Public Member Functions

 FastInputVectorPreprocessor (const std::vector< Input > &inputs, const std::vector< std::string > &order)
MatrixXd operator() (const MatrixXd &) const

Private Attributes

VectorXd m_offsets
VectorXd m_scales
std::vector< size_t > m_indices

Detailed Description

Definition at line 45 of file FastInputPreprocessor.h.

Constructor & Destructor Documentation

◆ FastInputVectorPreprocessor()

lwt::atlas::FastInputVectorPreprocessor::FastInputVectorPreprocessor ( const std::vector< Input > & inputs,
const std::vector< std::string > & order )

Definition at line 75 of file FastInputPreprocessor.cxx.

77 :
78 m_offsets(inputs.size()),
79 m_scales(inputs.size())
80 {
81 size_t in_num = 0;
82 for (const auto& input: inputs) {
83 m_offsets(in_num) = input.offset;
84 m_scales(in_num) = input.scale;
85 in_num++;
86 }
87 // require at least one input at configuration, since we require
88 // at least one for evaluation
89 if (in_num == 0) {
90 throw NNConfigurationException("need at least one input");
91 }
92 m_indices = get_value_indices(order, inputs);
93 }

Member Function Documentation

◆ operator()()

MatrixXd lwt::atlas::FastInputVectorPreprocessor::operator() ( const MatrixXd & in) const

Definition at line 94 of file FastInputPreprocessor.cxx.

94 {
95 using namespace Eigen;
96 size_t n_cols = in.cols();
97 MatrixXd inmat(m_indices.size(), n_cols);
98 size_t in_num = 0;
99 for (size_t index: m_indices) {
100 if (static_cast<int>(index) >= in.rows()) {
101 throw NNEvaluationException(
102 "index " + std::to_string(index) + " is out of range, sequence "
103 "input only has " + std::to_string(in.rows()) + " entries");
104 }
105 inmat.row(in_num) = in.row(index);
106 in_num++;
107 }
108 if (n_cols == 0) {
109 return MatrixXd(m_indices.size(), 0);
110 }
111 return m_scales.asDiagonal() * (inmat.colwise() + m_offsets);
112 }

Member Data Documentation

◆ m_indices

std::vector<size_t> lwt::atlas::FastInputVectorPreprocessor::m_indices
private

Definition at line 55 of file FastInputPreprocessor.h.

◆ m_offsets

VectorXd lwt::atlas::FastInputVectorPreprocessor::m_offsets
private

Definition at line 53 of file FastInputPreprocessor.h.

◆ m_scales

VectorXd lwt::atlas::FastInputVectorPreprocessor::m_scales
private

Definition at line 54 of file FastInputPreprocessor.h.


The documentation for this class was generated from the following files: