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

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

Inheritance diagram for keras::LayerConv2D:
keras::Layer keras::Layer

Public Member Functions

 LayerConv2D ()
 
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
 
 LayerConv2D ()
 
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::vector< std::vector< std::vector< std::vector< float > > > > m_kernels
 
std::vector< float > m_bias
 
std::string m_border_mode
 
int m_kernels_cnt
 
int m_depth
 
int m_rows
 
int m_cols
 
std::string m_name
 

Detailed Description

Definition at line 164 of file KerasModel.h.

Constructor & Destructor Documentation

keras::LayerConv2D::LayerConv2D ( )
inline

Definition at line 166 of file KerasModel.h.

References fin.

166 : Layer("Conv2D") {}
Layer(std::string name)
Definition: KerasModel.h:111
keras::LayerConv2D::LayerConv2D ( )
inline

Definition at line 164 of file KerasModel.h.

References fin.

164 : Layer("Conv2D") {}
Layer(std::string name)
Definition: KerasModel.h:111

Member Function Documentation

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

Implements keras::Layer.

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

Implements keras::Layer.

Definition at line 278 of file KerasModel.cxx.

References keras::conv_single_depth_same(), keras::conv_single_depth_valid(), keras::DataChunk::get_3d(), MECModelEnuComparisons::i, calib::j, m, confusionMatrixTree::out, keras::DataChunk::set_data(), gen_hdf5record::size, tmp, submit_syst::x, and submit_syst::y.

Referenced by keras::missing_activation_impl().

278  {
279 
280  unsigned int st_x = (m_kernels[0][0].size()-1)/2;
281  unsigned int st_y = (m_kernels[0][0][0].size()-1)/2;
282  vector< vector< vector<float> > > y_ret;
283  auto const & im = dc->get_3d();
284 
285  size_t size_x = (m_border_mode == "valid")? im[0].size() - 2 * st_x : im[0].size();
286  size_t size_y = (m_border_mode == "valid")? im[0][0].size() - 2 * st_y: im[0][0].size();
287  for(unsigned int i = 0; i < m_kernels.size(); ++i) { // depth
288  vector<vector<float> > tmp;
289  tmp.reserve(size_x);
290  for(unsigned int j = 0; j < size_x; ++j) { // rows
291  tmp.emplace_back(vector<float>(size_y, 0.0));
292  }
293  y_ret.push_back(tmp);
294  }
295 
296  for(unsigned int j = 0; j < m_kernels.size(); ++j) { // loop over kernels
297  for(unsigned int m = 0; m < im.size(); ++m) { // loope over image depth
298 
299  vector<vector<float> > tmp_w = (m_border_mode == "valid")?
302 
303  for(unsigned int x = 0; x < tmp_w.size(); ++x) {
304  for(unsigned int y = 0; y < tmp_w[0].size(); ++y) {
305  y_ret[j][x][y] += tmp_w[x][y];
306  }
307  }
308  }
309 
310  for(unsigned int x = 0; x < y_ret[0].size(); ++x) {
311  for(unsigned int y = 0; y < y_ret[0][0].size(); ++y) {
312  y_ret[j][x][y] += m_bias[j];
313  }
314  }
315  }
316 
318  out->set_data(y_ret);
319  return out;
320 }
std::vector< std::vector< float > > conv_single_depth_same(std::vector< std::vector< float > > const &im, std::vector< std::vector< float > > const &k)
Definition: KerasModel.cxx:250
virtual void set_data(std::vector< std::vector< std::vector< float > > > const &)
Definition: KerasModel.h:38
Float_t tmp
Definition: plot.C:36
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
Definition: KerasModel.h:37
std::vector< float > m_bias
Definition: KerasModel.h:171
std::vector< std::vector< std::vector< std::vector< float > > > > m_kernels
Definition: KerasModel.h:170
std::string m_border_mode
Definition: KerasModel.h:177
const double j
Definition: BetheBloch.cxx:29
std::vector< std::vector< float > > conv_single_depth_valid(std::vector< std::vector< float > > const &im, std::vector< std::vector< float > > const &k)
Definition: KerasModel.cxx:225
virtual unsigned int keras::LayerConv2D::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 172 of file KerasModel.h.

172 { return m_cols; }
virtual unsigned int keras::LayerConv2D::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 174 of file KerasModel.h.

174 { return m_cols; }
virtual unsigned int keras::LayerConv2D::get_input_rows ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 171 of file KerasModel.h.

171 { return m_rows; }
virtual unsigned int keras::LayerConv2D::get_input_rows ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 173 of file KerasModel.h.

173 { return m_rows; }
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::LayerConv2D::get_output_units ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 173 of file KerasModel.h.

References string.

173 { return m_kernels_cnt; }
virtual unsigned int keras::LayerConv2D::get_output_units ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 175 of file KerasModel.h.

175 { return m_kernels_cnt; }
void keras::LayerConv2D::load_weights ( std::ifstream &  fin)
virtual

Implements keras::Layer.

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

Implements keras::Layer.

Definition at line 40 of file KerasModel.cxx.

References plot_validation_datamc::c, d, r(), and compare_h5_caf::skip.

40  {
41  char tmp_char = ' ';
42  string tmp_str = "";
43  float tmp_float;
44  bool skip = false;
46  if (m_border_mode == "[") { m_border_mode = "valid"; skip = true; }
47 
48  // reading kernel weights
49  for(int k = 0; k < m_kernels_cnt; ++k) {
50  vector<vector<vector<float> > > tmp_depths;
51  for(int d = 0; d < m_depth; ++d) {
52  vector<vector<float> > tmp_single_depth;
53  for(int r = 0; r < m_rows; ++r) {
54  if (!skip) { fin >> tmp_char; } // for '['
55  else { skip = false; }
56  vector<float> tmp_row;
57  for(int c = 0; c < m_cols; ++c) {
58  fin >> tmp_float;
59  tmp_row.push_back(tmp_float);
60  }
61  fin >> tmp_char; // for ']'
62  tmp_single_depth.push_back(tmp_row);
63  }
64  tmp_depths.push_back(tmp_single_depth);
65  }
66  m_kernels.push_back(tmp_depths);
67  }
68  // reading kernel biases
69  fin >> tmp_char; // for '['
70  for(int k = 0; k < m_kernels_cnt; ++k) {
71  fin >> tmp_float;
72  m_bias.push_back(tmp_float);
73  }
74  fin >> tmp_char; // for ']'
75 
76 }
TString fin
Definition: Style.C:24
std::vector< float > m_bias
Definition: KerasModel.h:171
std::vector< std::vector< std::vector< std::vector< float > > > > m_kernels
Definition: KerasModel.h:170
std::string m_border_mode
Definition: KerasModel.h:177
Float_t d
Definition: plot.C:236
TRandom3 r(0)

Member Data Documentation

std::vector< float > keras::LayerConv2D::m_bias

Definition at line 171 of file KerasModel.h.

std::string keras::LayerConv2D::m_border_mode

Definition at line 177 of file KerasModel.h.

int keras::LayerConv2D::m_cols

Definition at line 181 of file KerasModel.h.

int keras::LayerConv2D::m_depth

Definition at line 179 of file KerasModel.h.

std::vector< std::vector< std::vector< std::vector< float > > > > keras::LayerConv2D::m_kernels

Definition at line 170 of file KerasModel.h.

int keras::LayerConv2D::m_kernels_cnt

Definition at line 178 of file KerasModel.h.

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

Definition at line 119 of file KerasModel.h.

int keras::LayerConv2D::m_rows

Definition at line 180 of file KerasModel.h.


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