Public Member Functions | Public Attributes | List of all members
keras::LayerActivation Class Reference

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-21/ExoticsTriggers/KerasModel.h"

Inheritance diagram for keras::LayerActivation:
keras::Layer keras::Layer

Public Member Functions

 LayerActivation ()
 
void load_weights (std::ifstream &fin)
 
keras::DataChunkcompute_output (keras::DataChunk *)
 
virtual unsigned int get_input_rows () const
 
virtual unsigned int get_input_cols () const
 
virtual unsigned int get_output_units () const
 
 LayerActivation ()
 
void load_weights (std::ifstream &fin)
 
keras::DataChunkcompute_output (keras::DataChunk *)
 
virtual unsigned int get_input_rows () const
 
virtual unsigned int get_input_cols () const
 
virtual unsigned int get_output_units () const
 
std::string get_name ()
 
std::string get_name ()
 

Public Attributes

std::string m_activation_type
 
std::string m_name
 

Detailed Description

Definition at line 151 of file KerasModel.h.

Constructor & Destructor Documentation

keras::LayerActivation::LayerActivation ( )
inline

Definition at line 153 of file KerasModel.h.

References fin.

153 : Layer("Activation") {}
Layer(std::string name)
Definition: KerasModel.h:111
keras::LayerActivation::LayerActivation ( )
inline

Definition at line 151 of file KerasModel.h.

References fin.

151 : Layer("Activation") {}
Layer(std::string name)
Definition: KerasModel.h:111

Member Function Documentation

keras::DataChunk* keras::LayerActivation::compute_output ( keras::DataChunk )
virtual

Implements keras::Layer.

keras::DataChunk * keras::LayerActivation::compute_output ( keras::DataChunk dc)
virtual

Implements keras::Layer.

Definition at line 174 of file KerasModel.cxx.

References stan::math::exp(), keras::DataChunk::get_1d(), keras::DataChunk::get_3d(), keras::DataChunk::get_data_dim(), MECModelEnuComparisons::i, calib::j, keras::missing_activation_impl(), confusionMatrixTree::out, keras::DataChunk::set_data(), sum, and submit_syst::y.

Referenced by keras::missing_activation_impl().

174  {
175 
176  if (dc->get_data_dim() == 3) {
177  vector<vector<vector<float> > > y = dc->get_3d();
178  if(m_activation_type == "relu") {
179  for(unsigned int i = 0; i < y.size(); ++i) {
180  for(unsigned int j = 0; j < y[0].size(); ++j) {
181  for(unsigned int k = 0; k < y[0][0].size(); ++k) {
182  if(y[i][j][k] < 0) y[i][j][k] = 0;
183  }
184  }
185  }
187  out->set_data(y);
188  return out;
189  } else {
191  }
192  } else if (dc->get_data_dim() == 1) { // flat data, use 1D
193  vector<float> y = dc->get_1d();
194  if(m_activation_type == "relu") {
195  for(unsigned int k = 0; k < y.size(); ++k) {
196  if(y[k] < 0) y[k] = 0;
197  }
198  } else if(m_activation_type == "softmax") {
199  float sum = 0.0;
200  for(unsigned int k = 0; k < y.size(); ++k) {
201  y[k] = exp(y[k]);
202  sum += y[k];
203  }
204  for(unsigned int k = 0; k < y.size(); ++k) {
205  y[k] /= sum;
206  }
207  } else if(m_activation_type == "sigmoid") {
208  for(unsigned int k = 0; k < y.size(); ++k) {
209  y[k] = 1/(1+exp(-y[k]));
210  }
211  } else {
213  }
214 
215  keras::DataChunk *out = new DataChunkFlat();
216  out->set_data(y);
217  return out;
218  } else { throw "data dim not supported"; }
219 
220  return dc;
221 }
virtual void set_data(std::vector< std::vector< std::vector< float > > > const &)
Definition: KerasModel.h:38
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
Definition: KerasModel.h:37
virtual size_t get_data_dim(void) const
Definition: KerasModel.h:35
std::string m_activation_type
Definition: KerasModel.h:161
fvar< T > exp(const fvar< T > &x)
Definition: exp.hpp:10
const double j
Definition: BetheBloch.cxx:29
void missing_activation_impl(const std::string &act)
Definition: KerasModel.cxx:176
Double_t sum
Definition: plot.C:31
virtual std::vector< float > const & get_1d() const
Definition: KerasModel.h:36
virtual unsigned int keras::LayerActivation::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 156 of file KerasModel.h.

156 { return 0; } // same as for rows
virtual unsigned int keras::LayerActivation::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 158 of file KerasModel.h.

158 { return 0; } // same as for rows
virtual unsigned int keras::LayerActivation::get_input_rows ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 155 of file KerasModel.h.

155 { return 0; } // look for the value in the preceding layer
virtual unsigned int keras::LayerActivation::get_input_rows ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 157 of file KerasModel.h.

157 { return 0; } // look for the value in the preceding layer
std::string keras::Layer::get_name ( )
inlineinherited

Definition at line 116 of file KerasModel.h.

References string.

116 { return m_name; }
std::string m_name
Definition: KerasModel.h:119
std::string keras::Layer::get_name ( )
inlineinherited

Definition at line 118 of file KerasModel.h.

118 { return m_name; }
std::string m_name
Definition: KerasModel.h:119
virtual unsigned int keras::LayerActivation::get_output_units ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 157 of file KerasModel.h.

References string.

157 { return 0; }
virtual unsigned int keras::LayerActivation::get_output_units ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 159 of file KerasModel.h.

159 { return 0; }
void keras::LayerActivation::load_weights ( std::ifstream &  fin)
virtual

Implements keras::Layer.

void keras::LayerActivation::load_weights ( std::ifstream &  fin)
virtual

Implements keras::Layer.

Definition at line 78 of file KerasModel.cxx.

78  {
80 }
TString fin
Definition: Style.C:24
std::string m_activation_type
Definition: KerasModel.h:161

Member Data Documentation

std::string keras::LayerActivation::m_activation_type

Definition at line 161 of file KerasModel.h.

std::string keras::Layer::m_name
inherited

Definition at line 119 of file KerasModel.h.


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