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

#include <keras_model.h>

Inheritance diagram for keras::DataChunk2D:
keras::DataChunk

Public Member Functions

 DataChunk2D (size_t depth, size_t rows, size_t cols, float init)
 
 DataChunk2D (void)
 
std::vector< std::vector< std::vector< float > > > & get_3d_rw ()
 
std::vector< std::vector< std::vector< float > > > const & get_3d () const
 
virtual void set_data (std::vector< std::vector< std::vector< float > > > const &d)
 
size_t get_data_dim (void) const
 
void show_name ()
 
void show_values ()
 
void read_from_file (const std::string &fname)
 
- Public Member Functions inherited from keras::DataChunk
virtual ~DataChunk ()
 
virtual std::vector< float > const & get_1d () const
 
virtual void set_data (std::vector< float > const &)
 

Public Attributes

std::vector< std::vector< std::vector< float > > > data
 
int m_depth
 
int m_rows
 
int m_cols
 

Detailed Description

Definition at line 55 of file keras_model.h.

Constructor & Destructor Documentation

keras::DataChunk2D::DataChunk2D ( size_t  depth,
size_t  rows,
size_t  cols,
float  init 
)
inline

Definition at line 57 of file keras_model.h.

57  :
58  data(depth, std::vector< std::vector<float> >(rows, std::vector<float>(cols, init)))
59  { }
struct vector vector
init
Definition: train.py:42
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
keras::DataChunk2D::DataChunk2D ( void  )
inline

Definition at line 60 of file keras_model.h.

60 { }

Member Function Documentation

std::vector< std::vector< std::vector<float> > > const& keras::DataChunk2D::get_3d ( ) const
inlinevirtual

Reimplemented from keras::DataChunk.

Definition at line 63 of file keras_model.h.

63 { return data; };
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
std::vector< std::vector< std::vector<float> > >& keras::DataChunk2D::get_3d_rw ( )
inline

Definition at line 62 of file keras_model.h.

62 { return data; };
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
size_t keras::DataChunk2D::get_data_dim ( void  ) const
inlinevirtual

Reimplemented from keras::DataChunk.

Definition at line 65 of file keras_model.h.

65 { return 3; }
void keras::DataChunk2D::read_from_file ( const std::string fname)
virtual

Reimplemented from keras::DataChunk.

Definition at line 24 of file keras_model.cc.

24  {
25  ifstream fin(fname.c_str());
26  fin >> m_depth >> m_rows >> m_cols;
27 
28  for(int d = 0; d < m_depth; ++d) {
29  vector<vector<float> > tmp_single_depth;
30  for(int r = 0; r < m_rows; ++r) {
31  vector<float> tmp_row = keras::read_1d_array(fin, m_cols);
32  tmp_single_depth.push_back(tmp_row);
33  }
34  data.push_back(tmp_single_depth);
35  }
36  fin.close();
37 }
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
std::vector< float > read_1d_array(std::ifstream &fin, int cols)
Definition: keras_model.cc:11
virtual void keras::DataChunk2D::set_data ( std::vector< std::vector< std::vector< float > > > const &  d)
inlinevirtual

Reimplemented from keras::DataChunk.

Definition at line 64 of file keras_model.h.

64 { data = d; };
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
void keras::DataChunk2D::show_name ( )
inlinevirtual

Implements keras::DataChunk.

Definition at line 67 of file keras_model.h.

67  {
68  std::cout << "DataChunk2D " << data.size() << "x" << data[0].size() << "x" << data[0][0].size() << std::endl;
69  }
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
QTextStream & endl(QTextStream &s)
void keras::DataChunk2D::show_values ( )
inlinevirtual

Implements keras::DataChunk.

Definition at line 71 of file keras_model.h.

71  {
72  std::cout << "DataChunk2D values:" << std::endl;
73  for(size_t i = 0; i < data.size(); ++i) {
74  std::cout << "Kernel " << i << std::endl;
75  for(size_t j = 0; j < data[0].size(); ++j) {
76  for(size_t k = 0; k < data[0][0].size(); ++k) {
77  std::cout << data[i][j][k] << " ";
78  }
79  std::cout << std::endl;
80  }
81  }
82  }
std::vector< std::vector< std::vector< float > > > data
Definition: keras_model.h:88
QTextStream & endl(QTextStream &s)

Member Data Documentation

std::vector<std::vector<std::vector<float> > > keras::DataChunk2D::data

Definition at line 88 of file keras_model.h.

int keras::DataChunk2D::m_cols

Definition at line 92 of file keras_model.h.

int keras::DataChunk2D::m_depth

Definition at line 90 of file keras_model.h.

int keras::DataChunk2D::m_rows

Definition at line 91 of file keras_model.h.


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