Public Member Functions | Public Attributes | List of all members
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
 
- Public Member Functions inherited from keras::Layer
 Layer (std::string name)
 
virtual ~Layer ()
 
std::string get_name ()
 

Public Attributes

int m_pool_x
 
int m_pool_y
 
- Public Attributes inherited from keras::Layer
std::string m_name
 

Detailed Description

Definition at line 148 of file keras_model.h.

Constructor & Destructor Documentation

keras::LayerMaxPooling::LayerMaxPooling ( )
inline

Definition at line 150 of file keras_model.h.

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

Member Function Documentation

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

Implements keras::Layer.

Definition at line 142 of file keras_model.cc.

142  {
143  vector<vector<vector<float> > > im = dc->get_3d();
144  vector<vector<vector<float> > > y_ret;
145  for(unsigned int i = 0; i < im.size(); ++i) {
146  vector<vector<float> > tmp_y;
147  for(unsigned int j = 0; j < (unsigned int)(im[0].size()/m_pool_x); ++j) {
148  tmp_y.push_back(vector<float>((int)(im[0][0].size()/m_pool_y), 0.0));
149  }
150  y_ret.push_back(tmp_y);
151  }
152  for(unsigned int d = 0; d < y_ret.size(); ++d) {
153  for(unsigned int x = 0; x < y_ret[0].size(); ++x) {
154  unsigned int start_x = x*m_pool_x;
155  unsigned int end_x = start_x + m_pool_x;
156  for(unsigned int y = 0; y < y_ret[0][0].size(); ++y) {
157  unsigned int start_y = y*m_pool_y;
158  unsigned int end_y = start_y + m_pool_y;
159 
160  vector<float> values;
161  for(unsigned int i = start_x; i < end_x; ++i) {
162  for(unsigned int j = start_y; j < end_y; ++j) {
163  values.push_back(im[d][i][j]);
164  }
165  }
166  y_ret[d][x][y] = *max_element(values.begin(), values.end());
167  }
168  }
169  }
171  out->set_data(y_ret);
172  return out;
173 }
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
Definition: keras_model.h:46
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
Definition: StdUtils.h:92
Q_UINT16 values[128]
list x
Definition: train.py:276
virtual unsigned int keras::LayerMaxPooling::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 156 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 155 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 157 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 86 of file keras_model.cc.

86  {
87  fin >> m_pool_x >> m_pool_y;
88  cout << "MaxPooling " << m_pool_x << "x" << m_pool_y << endl;
89 }
QTextStream & endl(QTextStream &s)

Member Data Documentation

int keras::LayerMaxPooling::m_pool_x

Definition at line 159 of file keras_model.h.

int keras::LayerMaxPooling::m_pool_y

Definition at line 160 of file keras_model.h.


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