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

#include "keras_model.h"

Inheritance diagram for keras::LayerMaxPooling:
keras::Layer

Public Member Functions

 LayerMaxPooling ()
 
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 ()
 

Public Attributes

int m_pool_x
 
int m_pool_y
 
std::string m_name
 

Detailed Description

Definition at line 158 of file keras_model.h.

Constructor & Destructor Documentation

keras::LayerMaxPooling::LayerMaxPooling ( )
inline

Definition at line 160 of file keras_model.h.

References fin.

160 : Layer("MaxPooling2D"){};
Layer(std::string name)
Definition: keras_model.h:133

Member Function Documentation

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

Implements keras::Layer.

Definition at line 149 of file keras_model.cc.

References d, keras::DataChunk::get_3d(), util::size(), util::values(), x, and y.

150 {
151  vector<vector<vector<float>>> im = dc->get_3d();
152  vector<vector<vector<float>>> y_ret;
153  for (unsigned int i = 0; i < im.size(); ++i) {
154  vector<vector<float>> tmp_y;
155  for (unsigned int j = 0; j < (unsigned int)(im[0].size() / m_pool_x); ++j) {
156  tmp_y.push_back(vector<float>((int)(im[0][0].size() / m_pool_y), 0.0));
157  }
158  y_ret.push_back(tmp_y);
159  }
160  for (unsigned int d = 0; d < y_ret.size(); ++d) {
161  for (unsigned int x = 0; x < y_ret[0].size(); ++x) {
162  unsigned int start_x = x * m_pool_x;
163  unsigned int end_x = start_x + m_pool_x;
164  for (unsigned int y = 0; y < y_ret[0][0].size(); ++y) {
165  unsigned int start_y = y * m_pool_y;
166  unsigned int end_y = start_y + m_pool_y;
167 
168  vector<float> values;
169  for (unsigned int i = start_x; i < end_x; ++i) {
170  for (unsigned int j = start_y; j < end_y; ++j) {
171  values.push_back(im[d][i][j]);
172  }
173  }
174  y_ret[d][x][y] = *max_element(values.begin(), values.end());
175  }
176  }
177  }
179  out->set_data(y_ret);
180  return out;
181 }
Float_t x
Definition: compare.C:6
Float_t y
Definition: compare.C:6
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
Definition: keras_model.h:49
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:101
decltype(auto) values(Coll &&coll)
Range-for loop helper iterating across the values of the specified collection.
Float_t d
Definition: plot.C:235
virtual unsigned int keras::LayerMaxPooling::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 169 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 165 of file keras_model.h.

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

Definition at line 140 of file keras_model.h.

140 { return m_name; }
std::string m_name
Definition: keras_model.h:141
virtual unsigned int keras::LayerMaxPooling::get_output_units ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 170 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 92 of file keras_model.cc.

93 {
94  fin >> m_pool_x >> m_pool_y;
95  cout << "MaxPooling " << m_pool_x << "x" << m_pool_y << endl;
96 }
TString fin
Definition: Style.C:24

Member Data Documentation

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

Definition at line 141 of file keras_model.h.

int keras::LayerMaxPooling::m_pool_x

Definition at line 172 of file keras_model.h.

int keras::LayerMaxPooling::m_pool_y

Definition at line 173 of file keras_model.h.


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