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

#include <keras_model.h>

Inheritance diagram for keras::LayerFlatten:
keras::Layer

Public Member Functions

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

Additional Inherited Members

- Public Attributes inherited from keras::Layer
std::string m_name
 

Detailed Description

Definition at line 136 of file keras_model.h.

Constructor & Destructor Documentation

keras::LayerFlatten::LayerFlatten ( )
inline

Definition at line 138 of file keras_model.h.

138 : Layer("Flatten") {}
Layer(std::string name)
Definition: keras_model.h:124

Member Function Documentation

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

Implements keras::Layer.

Definition at line 121 of file keras_model.cc.

121  {
122  vector<vector<vector<float> > > im = dc->get_3d();
123 
124  size_t csize = im[0].size();
125  size_t rsize = im[0][0].size();
126  size_t size = im.size() * csize * rsize;
127  keras::DataChunkFlat *out = new DataChunkFlat(size);
128  float * y_ret = out->get_1d_rw().data();
129  for(size_t i = 0, dst = 0; i < im.size(); ++i) {
130  for(size_t j = 0; j < csize; ++j) {
131  float * row = im[i][j].data();
132  for(size_t k = 0; k < rsize; ++k) {
133  y_ret[dst++] = row[k];
134  }
135  }
136  }
137 
138  return out;
139 }
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
std::vector< float > & get_1d_rw()
Definition: keras_model.h:102
virtual unsigned int keras::LayerFlatten::get_input_cols ( ) const
inlinevirtual

Implements keras::Layer.

Definition at line 143 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 142 of file keras_model.h.

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

Implements keras::Layer.

Definition at line 144 of file keras_model.h.

144 { return 0; }
void keras::LayerFlatten::load_weights ( std::ifstream &  fin)
inlinevirtual

Implements keras::Layer.

Definition at line 139 of file keras_model.h.

139 {};

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