LArSoft  v07_13_02
Liquid Argon Software toolkit - http://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 276 of file keras_model.cc.

References y.

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

280 {
281  size_t k1_size = k.size(), k2_size = k[0].size();
282  unsigned int st_x = (k1_size - 1) >> 1;
283  unsigned int st_y = (k2_size - 1) >> 1;
284 
285  size_t max_imc = im.size() - 1;
286  size_t max_imr = im[0].size() - 1;
287 
288  for(unsigned int i = 0; i < im.size(); ++i) {
289  for(unsigned int j = 0; j < im[0].size(); ++j) {
290 
291  float sum = 0;
292  for(unsigned int k1 = 0; k1 < k1_size; ++k1) {
293  //const float * k_data = k[k1_size-k1-1].data();
294  //const float * im_data = im[i-st_x+k1].data();
295  for(unsigned int k2 = 0; k2 < k2_size; ++k2) {
296  if(i+k1 < st_x) continue;
297  if(i+k1 > max_imc+st_x) continue;
298  if(j+k2 < st_y) continue;
299  if(j+k2 > max_imr+st_y) continue;
300 
301  //sum += k_data[k2_size-k2-1] * im_data[j-st_y+k2];
302  sum += k[k1_size-k1-1][k2_size-k2-1] * im[i-st_x+k1][j-st_y+k2];
303  }
304  }
305  y[i][j] += sum;
306  }
307  }
308 }
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 249 of file keras_model.cc.

References y.

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

253 {
254  size_t k1_size = k.size(), k2_size = k[0].size();
255  unsigned int st_x = (k1_size - 1) >> 1;
256  unsigned int st_y = (k2_size - 1) >> 1;
257 
258  for(unsigned int i = st_x; i < im.size()-st_x; ++i) {
259  for(unsigned int j = st_y; j < im[0].size()-st_y; ++j) {
260 
261  float sum = 0;
262  for(unsigned int k1 = 0; k1 < k1_size; ++k1) {
263  //const float * k_data = k[k1_size-k1-1].data();
264  //const float * im_data = im[i-st_x+k1].data();
265  for(unsigned int k2 = 0; k2 < k2_size; ++k2) {
266  //sum += k_data[k2_size-k2-1] * im_data[j-st_y+k2];
267  sum += k[k1_size-k1-1][k2_size-k2-1] * im[i-st_x+k1][j-st_y+k2];
268  }
269  }
270  y[i-st_x][j-st_y] += sum;
271  }
272  }
273 }
void keras::missing_activation_impl ( const std::string &  act)

Definition at line 178 of file keras_model.cc.

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

178  {
179  cout << "Activation " << act << " not defined!" << endl;
180  cout << "Please add its implementation before use." << endl;
181  exit(1);
182 }
std::vector< float > keras::read_1d_array ( std::ifstream &  fin,
int  cols 
)

Definition at line 14 of file keras_model.cc.

References n.

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

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