LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
keras Namespace Reference

Classes

class  DataChunk
 
class  DataChunk2D
 
class  DataChunkFlat
 
class  KerasModel
 
class  Layer
 
class  LayerActivation
 
class  LayerConv2D
 
class  LayerDense
 
class  LayerFlatten
 
class  LayerMaxPooling
 

Functions

std::vector< float > read_1d_array (std::ifstream &fin, int cols)
 
void missing_activation_impl (const std::string &act)
 
void conv_single_depth_valid (std::vector< std::vector< float >> &y, std::vector< std::vector< float >> const &im, std::vector< std::vector< float >> const &k)
 
void conv_single_depth_same (std::vector< std::vector< float >> &y, std::vector< std::vector< float >> const &im, std::vector< std::vector< float >> const &k)
 

Function Documentation

void keras::conv_single_depth_same ( std::vector< std::vector< float >> &  y,
std::vector< std::vector< float >> const &  im,
std::vector< std::vector< float >> const &  k 
)

Definition at line 290 of file keras_model.cc.

References sum, and y.

Referenced by keras::LayerConv2D::compute_output().

293 {
294  size_t k1_size = k.size(), k2_size = k[0].size();
295  unsigned int st_x = (k1_size - 1) >> 1;
296  unsigned int st_y = (k2_size - 1) >> 1;
297 
298  size_t max_imc = im.size() - 1;
299  size_t max_imr = im[0].size() - 1;
300 
301  for (unsigned int i = 0; i < im.size(); ++i) {
302  for (unsigned int j = 0; j < im[0].size(); ++j) {
303 
304  float sum = 0;
305  for (unsigned int k1 = 0; k1 < k1_size; ++k1) {
306  //const float * k_data = k[k1_size-k1-1].data();
307  //const float * im_data = im[i-st_x+k1].data();
308  for (unsigned int k2 = 0; k2 < k2_size; ++k2) {
309  if (i + k1 < st_x) continue;
310  if (i + k1 > max_imc + st_x) continue;
311  if (j + k2 < st_y) continue;
312  if (j + k2 > max_imr + st_y) continue;
313 
314  //sum += k_data[k2_size-k2-1] * im_data[j-st_y+k2];
315  sum += k[k1_size - k1 - 1][k2_size - k2 - 1] * im[i - st_x + k1][j - st_y + k2];
316  }
317  }
318  y[i][j] += sum;
319  }
320  }
321 }
Double_t sum
Definition: plot.C:31
void keras::conv_single_depth_valid ( std::vector< std::vector< float >> &  y,
std::vector< std::vector< float >> const &  im,
std::vector< std::vector< float >> const &  k 
)

Definition at line 264 of file keras_model.cc.

References sum, and y.

Referenced by keras::LayerConv2D::compute_output().

267 {
268  size_t k1_size = k.size(), k2_size = k[0].size();
269  unsigned int st_x = (k1_size - 1) >> 1;
270  unsigned int st_y = (k2_size - 1) >> 1;
271 
272  for (unsigned int i = st_x; i < im.size() - st_x; ++i) {
273  for (unsigned int j = st_y; j < im[0].size() - st_y; ++j) {
274 
275  float sum = 0;
276  for (unsigned int k1 = 0; k1 < k1_size; ++k1) {
277  //const float * k_data = k[k1_size-k1-1].data();
278  //const float * im_data = im[i-st_x+k1].data();
279  for (unsigned int k2 = 0; k2 < k2_size; ++k2) {
280  //sum += k_data[k2_size-k2-1] * im_data[j-st_y+k2];
281  sum += k[k1_size - k1 - 1][k2_size - k2 - 1] * im[i - st_x + k1][j - st_y + k2];
282  }
283  }
284  y[i - st_x][j - st_y] += sum;
285  }
286  }
287 }
Double_t sum
Definition: plot.C:31
void keras::missing_activation_impl ( const std::string &  act)

Definition at line 183 of file keras_model.cc.

Referenced by keras::LayerActivation::compute_output().

184 {
185  cout << "Activation " << act << " not defined!" << endl;
186  cout << "Please add its implementation before use." << endl;
187  exit(1);
188 }
std::vector< float > keras::read_1d_array ( std::ifstream &  fin,
int  cols 
)

Definition at line 10 of file keras_model.cc.

References n.

Referenced by keras::DataChunk2D::read_from_file().

11 {
12  vector<float> arr;
13  float tmp_float;
14  char tmp_char;
15  fin >> tmp_char; // for '['
16  for (int n = 0; n < cols; ++n) {
17  fin >> tmp_float;
18  arr.push_back(tmp_float);
19  }
20  fin >> tmp_char; // for ']'
21  return arr;
22 }
TString fin
Definition: Style.C:24
Char_t n[5]