ATLAS Offline Software
Classes | Public Types | Public Member Functions | Static Public Attributes | Private Member Functions | Private Attributes | List of all members
TTrainedNetwork Class Reference

#include <TTrainedNetwork.h>

Inheritance diagram for TTrainedNetwork:
Collaboration diagram for TTrainedNetwork:

Classes

struct  Input
 

Public Types

enum  ActivationFunction { SIGMOID = 1 }
 
typedef std::vector< Double_t > DVec
 
typedef std::map< std::string, double > DMap
 
typedef DMap::const_iterator DMapI
 

Public Member Functions

 TTrainedNetwork ()
 
 TTrainedNetwork (Int_t nInput, Int_t nHidden, Int_t nOutput, std::vector< Int_t > &nHiddenLayerSize, std::vector< TVectorD * > &thresholdVectors, std::vector< TMatrixD * > &weightMatrices, Int_t activationFunction, bool linearOutput=false, bool normalizeOutput=false)
 
 ~TTrainedNetwork ()
 
void setNewWeights (std::vector< TVectorD * > &thresholdVectors, std::vector< TMatrixD * > &weightMatrices)
 
Int_t getnInput () const
 
Int_t getnHidden () const
 
Int_t getnOutput () const
 
const std::vector< Int_t > & getnHiddenLayerSize () const
 
Int_t getActivationFunction () const
 
const std::vector< TVectorD * > & getThresholdVectors () const
 
const std::vector< TMatrixD * > & weightMatrices () const
 
std::vector< Double_t > calculateOutputValues (std::vector< Double_t > &input) const
 
bool getIfLinearOutput () const
 
bool getIfNormalizeOutput () const
 
 TTrainedNetwork ()
 
 TTrainedNetwork (Int_t nInput, Int_t nHidden, Int_t nOutput, std::vector< Int_t > &nHiddenLayerSize, std::vector< TVectorD * > &thresholdVectors, std::vector< TMatrixD * > &weightMatrices, Int_t activationFunction, bool linearOutput=false, bool normalizeOutput=false)
 
void setOffsets (const std::vector< double > &offsets)
 
void setScales (const std::vector< double > &scales)
 
 TTrainedNetwork (const std::vector< TTrainedNetwork::Input > &inputs, unsigned nOutput, std::vector< TVectorD * > &thresholdVectors, std::vector< TMatrixD * > &weightMatrices, ActivationFunction activationFunction=SIGMOID, unsigned options=0)
 
 ~TTrainedNetwork ()
 
std::vector< InputgetInputs () const
 
void setNewWeights (std::vector< TVectorD * > &thresholdVectors, std::vector< TMatrixD * > &weightMatrices)
 
Int_t getnInput () const
 
Int_t getnHidden () const
 
Int_t getnOutput () const
 
const std::vector< Int_t > & getnHiddenLayerSize () const
 
Int_t getActivationFunction () const
 
const std::vector< TVectorD * > & getThresholdVectors () const
 
const std::vector< TMatrixD * > & weightMatrices () const
 
DVec calculateOutputValues (const DVec &input) const
 
DVec calculateNormalized (const DVec &input) const
 
DVec calculateNormalized (const DMap &input) const
 
bool getIfLinearOutput () const
 
bool getIfNormalizeOutput () const
 

Static Public Attributes

static const unsigned linearOutput = 1u << 0
 
static const unsigned normalizeOutput = 1u << 1
 

Private Member Functions

Double_t sigmoid (Double_t x) const
 
Double_t sigmoid (Double_t x) const
 
bool is_consistent () const
 
bool check_norm_size (unsigned size) const
 

Private Attributes

Int_t m_nInput
 
Int_t m_nHidden
 
Int_t m_nOutput
 
std::vector< Int_t > m_nHiddenLayerSize
 
std::vector< TVectorD * > m_ThresholdVectors
 
std::vector< TMatrixD * > m_WeightMatrices
 
Int_t m_ActivationFunction
 cache of the maximum needed size, not persisitified More...
 
bool m_LinearOutput
 
bool m_NormalizeOutput
 
unsigned m_nInput
 
unsigned m_nHidden
 
unsigned m_nOutput
 
std::vector< Double_t > m_input_node_offset
 
std::vector< Double_t > m_input_node_scale
 
std::map< std::string, int > m_inputStringToNode
 
unsigned int m_bufferSizeMax
 
double m_maxExpValue
 

Detailed Description

Definition at line 20 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h.

Member Typedef Documentation

◆ DMap

typedef std::map<std::string, double> TTrainedNetwork::DMap

◆ DMapI

typedef DMap::const_iterator TTrainedNetwork::DMapI

◆ DVec

typedef std::vector<Double_t> TTrainedNetwork::DVec

Member Enumeration Documentation

◆ ActivationFunction

Enumerator
SIGMOID 

Definition at line 33 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h.

33  {
34  SIGMOID = 1
35  };

Constructor & Destructor Documentation

◆ TTrainedNetwork() [1/5]

TTrainedNetwork::TTrainedNetwork ( )

◆ TTrainedNetwork() [2/5]

TTrainedNetwork::TTrainedNetwork ( Int_t  nInput,
Int_t  nHidden,
Int_t  nOutput,
std::vector< Int_t > &  nHiddenLayerSize,
std::vector< TVectorD * > &  thresholdVectors,
std::vector< TMatrixD * > &  weightMatrices,
Int_t  activationFunction,
bool  linearOutput = false,
bool  normalizeOutput = false 
)

Definition at line 22 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.cxx.

31  : m_nInput (nInput),
32  m_nHidden (nHidden),
33  m_nOutput (nOutput),
34  m_nHiddenLayerSize (nHiddenLayerSize),
35  m_ThresholdVectors (thresholdVectors),
37  m_ActivationFunction (activationFunction),
40 {
41 }

◆ ~TTrainedNetwork() [1/2]

TTrainedNetwork::~TTrainedNetwork ( )

Definition at line 43 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.cxx.

44 {
45  std::vector<TVectorD*>::const_iterator vectBegin=m_ThresholdVectors.begin();
46  std::vector<TVectorD*>::const_iterator vectEnd=m_ThresholdVectors.end();
47 
48  for (std::vector<TVectorD*>::const_iterator vectIter=vectBegin;
49  vectIter!=vectEnd;
50  ++vectIter)
51  {
52  delete *vectIter;
53  }
54 
55  std::vector<TMatrixD*>::const_iterator matrixBegin=m_WeightMatrices.begin();
56  std::vector<TMatrixD*>::const_iterator matrixEnd=m_WeightMatrices.end();
57 
58  for (std::vector<TMatrixD*>::const_iterator matrixIter=matrixBegin;
59  matrixIter!=matrixEnd;
60  ++matrixIter)
61  {
62  delete *matrixIter;
63  }
64 
65 }

◆ TTrainedNetwork() [3/5]

TTrainedNetwork::TTrainedNetwork ( )

◆ TTrainedNetwork() [4/5]

TTrainedNetwork::TTrainedNetwork ( Int_t  nInput,
Int_t  nHidden,
Int_t  nOutput,
std::vector< Int_t > &  nHiddenLayerSize,
std::vector< TVectorD * > &  thresholdVectors,
std::vector< TMatrixD * > &  weightMatrices,
Int_t  activationFunction,
bool  linearOutput = false,
bool  normalizeOutput = false 
)

◆ TTrainedNetwork() [5/5]

TTrainedNetwork::TTrainedNetwork ( const std::vector< TTrainedNetwork::Input > &  inputs,
unsigned  nOutput,
std::vector< TVectorD * > &  thresholdVectors,
std::vector< TMatrixD * > &  weightMatrices,
ActivationFunction  activationFunction = SIGMOID,
unsigned  options = 0 
)

Definition at line 76 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

82 {
83  m_nInput = inputs.size();
84  m_nHidden = thresholdVectors.size() - 1;
85  m_nOutput = nOutput;
86  m_ThresholdVectors = thresholdVectors;
88  m_ActivationFunction = activationFunction;
92 
93  std::vector<TVectorD*>::const_iterator hidden_layer_threshold_vector_end =
94  m_ThresholdVectors.end();
95  --hidden_layer_threshold_vector_end;
96 
97  for (std::vector<TVectorD*>::const_iterator tr_itr
98  = m_ThresholdVectors.begin();
99  tr_itr != hidden_layer_threshold_vector_end;
100  ++tr_itr){
101  m_nHiddenLayerSize.push_back((*tr_itr)->GetNrows());
102  }
103 
104  unsigned node_n = 0;
105  for (const auto & input : inputs) {
106  m_input_node_offset.push_back(input.offset);
107  m_input_node_scale.push_back(input.scale);
108  if (!input.name.empty()) {
109  m_inputStringToNode[input.name] = node_n;
110  }
111  node_n++;
112  }
113 
114  unsigned n_node = node_n;
115  assert(n_node == m_input_node_offset.size());
116  assert(n_node == m_input_node_scale.size());
117 
118  // mapping should either be unique or non-existent
119  unsigned n_mapped = m_inputStringToNode.size();
120  if (n_node != n_mapped && n_mapped != 0) {
121  throw std::runtime_error("Names for NN inputs must be unique (if given)");
122  }
123 
124  int nlayer_max(m_nOutput);
125  for (int & i : m_nHiddenLayerSize)
126  nlayer_max = std::max(nlayer_max, i);
127  m_bufferSizeMax=nlayer_max;
128 
129  unsigned n_zero = std::count(m_input_node_scale.begin(),
130  m_input_node_scale.end(), 0);
131  if (n_zero == n_node) {
132  m_input_node_scale.clear();
133  m_input_node_offset.clear();
134  }
135 
136  assert(is_consistent());
137 }

◆ ~TTrainedNetwork() [2/2]

TTrainedNetwork::~TTrainedNetwork ( )

Member Function Documentation

◆ calculateNormalized() [1/2]

std::vector< Double_t > TTrainedNetwork::calculateNormalized ( const DMap input) const

Definition at line 225 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

226  {
227 
228  std::vector<Double_t> inputs(m_nInput);
229  size_t n_filled = 0;
230  for (const auto & itr : in){
231  std::map<std::string,int>::const_iterator input_node_ptr =
232  m_inputStringToNode.find(itr.first);
233  if (input_node_ptr == m_inputStringToNode.end()) {
234  throw std::runtime_error(itr.first + "not found in NN");
235  }
236 
237  const int node_n = input_node_ptr->second;
238 
239  // get and scale the raw input value
240  double raw_value = itr.second;
241  raw_value += m_input_node_offset.at(node_n);
242  raw_value *= m_input_node_scale.at(node_n);
243 
244  // store in the inputs vector
245  inputs.at(node_n) = raw_value;
246  n_filled++;
247  }
248 
249  // make sure all nodes are filled
250  if (n_filled != m_inputStringToNode.size() ) {
251  assert(n_filled < m_inputStringToNode.size() );
252  std::set<std::string> input_set;
253  for (const auto & itr : in) {
254  input_set.insert(itr.first);
255  }
256  std::string err = "nodes not filled in NN: ";
257  for (const auto & itr : m_inputStringToNode){
258  if (input_set.find(itr.first) == input_set.end() )
259  err.append(itr.first + " ");
260  }
261  throw std::runtime_error(err);
262  }
263  return calculateOutputValues(inputs);
264 }

◆ calculateNormalized() [2/2]

std::vector< Double_t > TTrainedNetwork::calculateNormalized ( const DVec input) const

Definition at line 267 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

269 {
270  // asserts can be turned off in optomized code anyway,
271  // use them to be safe without having to call vector.at()
272  assert(m_nInput == input.size());
273  assert(m_nInput == m_input_node_scale.size());
274  assert(m_nInput == m_input_node_offset.size());
275  std::vector<double> transformed_inputs(input);
276  for (unsigned input_n = 0; input_n < m_nInput; input_n++) {
277  transformed_inputs[input_n] += m_input_node_offset[input_n];
278  transformed_inputs[input_n] *= m_input_node_scale[input_n];
279  }
280  return calculateOutputValues(transformed_inputs);
281 }

◆ calculateOutputValues() [1/2]

std::vector< Double_t > TTrainedNetwork::calculateOutputValues ( const DVec input) const

Definition at line 283 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

285 {
286  // This method is now highly optimised (apart from the potential use
287  // of a cheaper sigmoid function). Please be very careful changing
288  // anything here since it is used heavily in reconstruction during
289  // Pixel clusterization - Thomas Kittelmann, Oct 2011.
290 
291 
292  if (input.size() != m_nInput)
293  {
294  std::cerr << "TTrainedNetwork WARNING Input size: " << input.size()
295  << " does not match with network: " << m_nInput << std::endl;
296  return {};
297  }
298 
299  TTN::DoubleBuffer_t tmp_array;
300  tmp_array.clear(m_bufferSizeMax); // make sure it is big enough and initialise with zero
301 
302  const unsigned nTargetLayers(m_nHidden+1);
303  const unsigned lastTargetLayer(m_nHidden);
304  unsigned nSource = m_nInput, nTarget(0);
306  const double * weights(nullptr);
307  const double * thresholds(nullptr);
308  double nodeVal(0);
309 
310  for (unsigned iLayer = 0; iLayer < nTargetLayers; ++iLayer) {
311  //Find data area for target layer:
312  nTarget = ( iLayer == lastTargetLayer ?
313  m_nOutput :
314  m_nHiddenLayerSize[iLayer] );
315  TTN::Buffer_t target( tmp_array[iLayer] );
316 
317  //Transfer the input nodes to the output nodes in this layer transition:
318  weights = m_WeightMatrices[iLayer]->GetMatrixArray();
319  thresholds = m_ThresholdVectors[iLayer]->GetMatrixArray();
320  for (unsigned inodeTarget=0;inodeTarget<nTarget;++inodeTarget) {
321  nodeVal = 0.0;//Better would be "nodeVal = *thresholds++" and
322  //remove the line further down, but this way we
323  //get exactly the same results that an earlier
324  //version of the package gave.
325  const double * weights_tmp = weights++;
326  const double * source_end(&(source.upper_bound_at(nSource)));
327  for (const double* source_iter = &source[0];
328  source_iter != source_end; ++source_iter)
329  {
330  nodeVal += (*weights_tmp) * (*source_iter);
331  weights_tmp += nTarget;
332  }
333  nodeVal += *thresholds++;//see remark above.
334  target[inodeTarget] = ( m_LinearOutput && iLayer == lastTargetLayer )
335  ? nodeVal : sigmoid(nodeVal);
336  }
337  //Prepare for next layer transition:
338  source = target;
339  nSource = nTarget;
340  }
341 
342  //std::vector<double> result(nTarget);
343  if (!m_NormalizeOutput) {
344  // std::memcpy(&result[0], target, sizeof(*target)*nTarget);
345  // the result is already in the buffer half with index (nTargetLayers-1)%2
346  // copy this to the front of the full buffer and shrink the array
347  return tmp_array.releaseData(nTarget,(nTargetLayers-1));
348  } else {
349  // take the other half buffer to store the normalised output
350  TTN::Buffer_t norm_target=tmp_array[nTargetLayers];
351  TTN::Buffer_t target=tmp_array[(nTargetLayers-1)];
352  const double sumLastLayer =
353  std::accumulate(&target[0], &target[nTarget], 0.0 );
354  const double normFact = sumLastLayer ? 1.0/sumLastLayer : 0.0;
355  for (unsigned i = 0; i < nTarget; ++i)
356  norm_target[i] = normFact * target[i];
357  // copy the half buffer to the front of the full buffer
358  // if necessary and shrink the array
359  return tmp_array.releaseData(nTarget,nTargetLayers);
360  }
361 
362 }

◆ calculateOutputValues() [2/2]

std::vector< Double_t > TTrainedNetwork::calculateOutputValues ( std::vector< Double_t > &  input) const

Definition at line 99 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.cxx.

100 {
101 
102  std::vector<Double_t> result;
103 
104  //now calculate the value using:
105  TVectorD** resultVector=new TVectorD*[m_nHidden+1];
106 
107 
108  if ((int)input.size()!=m_nInput)
109  {
110  std::cout << " Input size: " << input.size() << " doesn't match with network: " << m_nInput << std::endl;
111  delete[] resultVector;
112  return result;
113  }
114 
115  for (Int_t o=0;o<m_nHidden+1;++o)
116  {
117 
118  int sizeActualLayer=(o<m_nHidden)?m_nHiddenLayerSize[o]:m_nOutput;
119 // int sizePreviousLayer=(o==0)?m_nInput:m_nHiddenLayerSize[o-1];
120 
121  resultVector[o]=new TVectorD(sizeActualLayer);
122 
123  for (Int_t s=0;s<sizeActualLayer;++s)
124  {
125  Double_t nodeValue=0.;
126  if (o==0)
127  {
128  for (Int_t p=0;p<m_nInput;++p)
129  {
130  nodeValue+=m_WeightMatrices[o]->operator() (p,s)*input[p];
131  }
132  }
133  else
134  {
135  for (Int_t p=0;p<m_nHiddenLayerSize[o-1];++p)
136  {
137  nodeValue+=m_WeightMatrices[o]->operator() (p,s)*resultVector[o-1]->operator()(p);
138  }
139  }
140  nodeValue+=m_ThresholdVectors[o]->operator() (s);
141  if (o!=m_nHidden || (!m_LinearOutput))
142  {
143  resultVector[o]->operator()(s) = sigmoid(nodeValue);
144  }
145  else
146  {
147  resultVector[o]->operator()(s) = nodeValue;
148  }
149  }
150  }
151 
152  double sumLastLayer=0;
153 
154  if (m_NormalizeOutput)
155  {
156  for (Int_t i=0;i<m_nOutput;i++)
157  {
158  sumLastLayer+=resultVector[m_nHidden]->operator()(i);
159  }
160  }
161 
162 
163  for (Int_t i=0;i<m_nOutput;i++)
164  {
165  if (!m_NormalizeOutput)
166  {
167  result.push_back(resultVector[m_nHidden]->operator()(i));
168  }
169  else
170  {
171  result.push_back(resultVector[m_nHidden]->operator()(i)/sumLastLayer);
172  }
173  }
174 
175  for (Int_t o=0;o<m_nHidden+1;++o)
176  {
177  //int sizeActualLayer=(o<m_nHidden)?m_nHiddenLayerSize[o]:m_nOutput;
178  delete resultVector[o];
179  }
180  delete[] resultVector;
181 
182  return result;
183 
184 }

◆ check_norm_size()

bool TTrainedNetwork::check_norm_size ( unsigned  size) const
private

Definition at line 412 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

412  {
413  if (size != m_nInput) {
414  std::cerr << "ERROR: TTrainedNetwork has " << m_nInput << " inputs, "
415  << size << " normalization values provided\n";
416  return false;
417  }
418  return true;
419 }

◆ getActivationFunction() [1/2]

Int_t TTrainedNetwork::getActivationFunction ( ) const
inline

◆ getActivationFunction() [2/2]

Int_t TTrainedNetwork::getActivationFunction ( ) const
inline

◆ getIfLinearOutput() [1/2]

bool TTrainedNetwork::getIfLinearOutput ( ) const
inline

◆ getIfLinearOutput() [2/2]

bool TTrainedNetwork::getIfLinearOutput ( ) const
inline

◆ getIfNormalizeOutput() [1/2]

bool TTrainedNetwork::getIfNormalizeOutput ( ) const
inline

◆ getIfNormalizeOutput() [2/2]

bool TTrainedNetwork::getIfNormalizeOutput ( ) const
inline

◆ getInputs()

std::vector< TTrainedNetwork::Input > TTrainedNetwork::getInputs ( ) const

Definition at line 163 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

163  {
164 
165  assert(m_inputStringToNode.size() == 0 ||
166  m_inputStringToNode.size() == m_nInput);
167  assert(m_input_node_scale.size() == m_input_node_offset.size());
168 
169  std::map<int,std::string> input_n_to_name;
170  for (const auto & itr : m_inputStringToNode){
171  input_n_to_name[itr.second] = itr.first;
172  }
173 
174  std::vector<Input> inputs_vector;
175  if (m_input_node_offset.size() != m_nInput) {
176  return inputs_vector;
177  }
178  for (unsigned input_n = 0; input_n < m_nInput; input_n++){
179  std::map<int,std::string>::const_iterator
180  name_itr = input_n_to_name.find(input_n);
181  Input the_input;
182  if (name_itr != input_n_to_name.end()) {
183  the_input.name = name_itr->second;
184  }
185  the_input.offset = m_input_node_offset.at(input_n);
186  the_input.scale = m_input_node_scale.at(input_n);
187  inputs_vector.push_back(the_input);
188  }
189  return inputs_vector;
190 }

◆ getnHidden() [1/2]

Int_t TTrainedNetwork::getnHidden ( ) const
inline

◆ getnHidden() [2/2]

Int_t TTrainedNetwork::getnHidden ( ) const
inline

◆ getnHiddenLayerSize() [1/2]

const std::vector<Int_t>& TTrainedNetwork::getnHiddenLayerSize ( ) const
inline

◆ getnHiddenLayerSize() [2/2]

const std::vector<Int_t>& TTrainedNetwork::getnHiddenLayerSize ( ) const
inline

◆ getnInput() [1/2]

Int_t TTrainedNetwork::getnInput ( ) const
inline

◆ getnInput() [2/2]

Int_t TTrainedNetwork::getnInput ( ) const
inline

◆ getnOutput() [1/2]

Int_t TTrainedNetwork::getnOutput ( ) const
inline

◆ getnOutput() [2/2]

Int_t TTrainedNetwork::getnOutput ( ) const
inline

◆ getThresholdVectors() [1/2]

const std::vector<TVectorD*>& TTrainedNetwork::getThresholdVectors ( ) const
inline

◆ getThresholdVectors() [2/2]

const std::vector<TVectorD*>& TTrainedNetwork::getThresholdVectors ( ) const
inline

◆ is_consistent()

bool TTrainedNetwork::is_consistent ( ) const
private

Definition at line 372 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

372  {
373  if (m_ThresholdVectors.size() != m_WeightMatrices.size()) {
374  std::cerr << "ERROR: "
375  << "n threshold vectors: " << m_ThresholdVectors.size()
376  << " n weight matrices: " << m_WeightMatrices.size()
377  << std::endl;
378  return false;
379  }
380  int nodes_last_layer = m_nInput;
381  for (unsigned layer_n = 0; layer_n < m_ThresholdVectors.size(); layer_n++){
382  int n_threshold_nodes = m_ThresholdVectors.at(layer_n)->GetNrows();
383  int n_weights_nodes = m_WeightMatrices.at(layer_n)->GetNcols();
384  if (n_threshold_nodes != n_weights_nodes) {
385  std::cerr << "ERROR: in layer " << layer_n
386  << " --- n threshold: " << n_threshold_nodes
387  << " n_weights: " << n_weights_nodes << std::endl;
388  return false;
389  }
390  int n_incoming_connections = m_WeightMatrices.at(layer_n)->GetNrows();
391  if (n_incoming_connections != nodes_last_layer) {
392  std::cerr << "ERROR: in layer " << layer_n
393  << " --- last layer nodes: " << nodes_last_layer
394  << " connected to this layer: " << n_incoming_connections
395  << std::endl;
396  return false;
397  }
398  nodes_last_layer = n_weights_nodes;
399  }
400 
401  if (m_ThresholdVectors.size() - 1 != m_nHiddenLayerSize.size() ){
402  std::cerr << "ERROR: "
403  << "size m_ThresholdVectors: " << m_ThresholdVectors.size()
404  << " size m_nHiddenLayerSize: " << m_nHiddenLayerSize.size()
405  << std::endl;
406  return false;
407  }
408 
409  return true;
410 }

◆ setNewWeights() [1/2]

void TTrainedNetwork::setNewWeights ( std::vector< TVectorD * > &  thresholdVectors,
std::vector< TMatrixD * > &  weightMatrices 
)

Definition at line 67 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.cxx.

69 {
70 
71  std::vector<TVectorD*>::const_iterator vectBegin=m_ThresholdVectors.begin();
72  std::vector<TVectorD*>::const_iterator vectEnd=m_ThresholdVectors.end();
73 
74  for (std::vector<TVectorD*>::const_iterator vectIter=vectBegin;
75  vectIter!=vectEnd;
76  ++vectIter)
77  {
78  delete *vectIter;
79  }
80 
81  std::vector<TMatrixD*>::const_iterator matrixBegin=m_WeightMatrices.begin();
82  std::vector<TMatrixD*>::const_iterator matrixEnd=m_WeightMatrices.end();
83 
84  for (std::vector<TMatrixD*>::const_iterator matrixIter=matrixBegin;
85  matrixIter!=matrixEnd;
86  ++matrixIter)
87  {
88  delete *matrixIter;
89  }
90 
91  m_ThresholdVectors.clear();
92  m_WeightMatrices.clear();
93 
94  m_ThresholdVectors=thresholdVectors;
96 
97 }

◆ setNewWeights() [2/2]

void TTrainedNetwork::setNewWeights ( std::vector< TVectorD * > &  thresholdVectors,
std::vector< TMatrixD * > &  weightMatrices 
)

◆ setOffsets()

void TTrainedNetwork::setOffsets ( const std::vector< double > &  offsets)

Definition at line 65 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

66 {
67  assert(check_norm_size(offsets.size()));
68  m_input_node_offset = offsets;
69 }

◆ setScales()

void TTrainedNetwork::setScales ( const std::vector< double > &  scales)

Definition at line 70 of file Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx.

71 {
72  assert(check_norm_size(scales.size()));
73  m_input_node_scale = scales;
74 }

◆ sigmoid() [1/2]

Double_t TTrainedNetwork::sigmoid ( Double_t  x) const
inlineprivate

◆ sigmoid() [2/2]

Double_t TTrainedNetwork::sigmoid ( Double_t  x) const
private

◆ weightMatrices() [1/2]

const std::vector<TMatrixD*>& TTrainedNetwork::weightMatrices ( ) const
inline

◆ weightMatrices() [2/2]

const std::vector<TMatrixD*>& TTrainedNetwork::weightMatrices ( ) const
inline

Member Data Documentation

◆ linearOutput

const unsigned TTrainedNetwork::linearOutput = 1u << 0
static

◆ m_ActivationFunction

Int_t TTrainedNetwork::m_ActivationFunction
private

cache of the maximum needed size, not persisitified

Definition at line 79 of file InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h.

◆ m_bufferSizeMax

unsigned int TTrainedNetwork::m_bufferSizeMax
private

◆ m_input_node_offset

std::vector<Double_t> TTrainedNetwork::m_input_node_offset
private

◆ m_input_node_scale

std::vector<Double_t> TTrainedNetwork::m_input_node_scale
private

◆ m_inputStringToNode

std::map<std::string,int> TTrainedNetwork::m_inputStringToNode
private

◆ m_LinearOutput

bool TTrainedNetwork::m_LinearOutput
private

◆ m_maxExpValue

double TTrainedNetwork::m_maxExpValue
private

◆ m_nHidden [1/2]

Int_t TTrainedNetwork::m_nHidden
private

◆ m_nHidden [2/2]

unsigned TTrainedNetwork::m_nHidden
private

◆ m_nHiddenLayerSize

std::vector< Int_t > TTrainedNetwork::m_nHiddenLayerSize
private

◆ m_nInput [1/2]

Int_t TTrainedNetwork::m_nInput
private

◆ m_nInput [2/2]

unsigned TTrainedNetwork::m_nInput
private

◆ m_NormalizeOutput

bool TTrainedNetwork::m_NormalizeOutput
private

◆ m_nOutput [1/2]

Int_t TTrainedNetwork::m_nOutput
private

◆ m_nOutput [2/2]

unsigned TTrainedNetwork::m_nOutput
private

◆ m_ThresholdVectors

std::vector< TVectorD * > TTrainedNetwork::m_ThresholdVectors
private

◆ m_WeightMatrices

std::vector< TMatrixD * > TTrainedNetwork::m_WeightMatrices
private

◆ normalizeOutput

const unsigned TTrainedNetwork::normalizeOutput = 1u << 1
static

The documentation for this class was generated from the following files:
TTN::DoubleBuffer_t::releaseData
std::vector< double > releaseData(std::vector< double >::size_type final_size, unsigned int fold_idx)
move the final result to its destination
Definition: TargetBuffer_t.h:181
TTrainedNetwork::calculateOutputValues
std::vector< Double_t > calculateOutputValues(std::vector< Double_t > &input) const
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.cxx:99
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
get_generator_info.result
result
Definition: get_generator_info.py:21
TTrainedNetwork::m_nHiddenLayerSize
std::vector< Int_t > m_nHiddenLayerSize
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:72
TTrainedNetwork::m_LinearOutput
bool m_LinearOutput
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:81
max
constexpr double max()
Definition: ap_fixedTest.cxx:33
accumulate
bool accumulate(AccumulateMap &map, std::vector< module_t > const &modules, FPGATrackSimMatrixAccumulator const &acc)
Accumulates an accumulator (e.g.
Definition: FPGATrackSimMatrixAccumulator.cxx:22
TTrainedNetwork::m_nInput
Int_t m_nInput
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:64
TTrainedNetwork::m_NormalizeOutput
bool m_NormalizeOutput
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:83
postInclude.inputs
inputs
Definition: postInclude.SortInput.py:15
TTrainedNetwork::weightMatrices
const std::vector< TMatrixD * > & weightMatrices() const
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:58
XMLtoHeader.count
count
Definition: XMLtoHeader.py:85
TTrainedNetwork::m_inputStringToNode
std::map< std::string, int > m_inputStringToNode
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:133
TTrainedNetwork::m_nHidden
Int_t m_nHidden
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:69
TTN::DoubleBuffer_t::clear
void clear(unsigned int max_buffer)
Definition: TargetBuffer_t.h:166
python.setupRTTAlg.size
int size
Definition: setupRTTAlg.py:39
TTrainedNetwork::m_maxExpValue
double m_maxExpValue
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:148
TTrainedNetwork::is_consistent
bool is_consistent() const
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx:372
python.utils.AtlRunQueryDQUtils.p
p
Definition: AtlRunQueryDQUtils.py:210
dqt_zlumi_pandas.err
err
Definition: dqt_zlumi_pandas.py:182
lumiFormat.i
int i
Definition: lumiFormat.py:85
TTN::Buffer_t
Reference to one of the halves provided by the DoubleBuffer_t.
Definition: TargetBuffer_t.h:125
TTrainedNetwork::check_norm_size
bool check_norm_size(unsigned size) const
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/src/TTrainedNetwork.cxx:412
PlotPulseshapeFromCool.input
input
Definition: PlotPulseshapeFromCool.py:106
TTrainedNetwork::m_nOutput
Int_t m_nOutput
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:70
python.AtlRunQueryLib.options
options
Definition: AtlRunQueryLib.py:379
TTrainedNetwork::m_WeightMatrices
std::vector< TMatrixD * > m_WeightMatrices
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:76
TTN::ConstBuffer_t
Read only reference to one of the halves provided by the DoubleBuffer_t.
Definition: TargetBuffer_t.h:146
TTrainedNetwork::m_ThresholdVectors
std::vector< TVectorD * > m_ThresholdVectors
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:75
TTrainedNetwork::sigmoid
Double_t sigmoid(Double_t x) const
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:85
weights
Definition: herwig7_interface.h:38
TTrainedNetwork::SIGMOID
@ SIGMOID
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:34
TTrainedNetwork::normalizeOutput
static const unsigned normalizeOutput
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:31
TTN::DoubleBuffer_t
The temporary buffer for internal computations which is split into two halves.
Definition: TargetBuffer_t.h:164
TTrainedNetwork::m_ActivationFunction
Int_t m_ActivationFunction
cache of the maximum needed size, not persisitified
Definition: InnerDetector/InDetCalibAlgs/PixelCalibAlgs/NNClusteringCalibration_RunI/TTrainedNetwork.h:79
copySelective.target
string target
Definition: copySelective.py:37
python.CaloCondTools.log
log
Definition: CaloCondTools.py:20
copySelective.source
string source
Definition: copySelective.py:32
NswErrorCalibData::Input
Helper struct to be parsed to the object to derive the specific error of the cluster.
Definition: NswErrorCalibData.h:25
TTrainedNetwork::m_input_node_offset
std::vector< Double_t > m_input_node_offset
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:130
TTrainedNetwork::linearOutput
static const unsigned linearOutput
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:30
TTrainedNetwork::m_bufferSizeMax
unsigned int m_bufferSizeMax
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:140
TTrainedNetwork::m_input_node_scale
std::vector< Double_t > m_input_node_scale
Definition: Tracking/TrkUtilityPackages/TrkNeuralNetworkUtils/TrkNeuralNetworkUtils/TTrainedNetwork.h:131