12 #ifndef KERAS_MODEL__H 13 #define KERAS_MODEL__H 45 virtual std::vector<float>
const &
get_1d()
const {
throw "not implemented"; };
46 virtual std::vector<std::vector<std::vector<float> > >
const &
get_3d()
const {
throw "not implemented"; };
48 virtual void set_data(std::vector<float>
const &) {};
57 DataChunk2D(
size_t depth,
size_t rows,
size_t cols,
float init) :
62 std::vector< std::vector< std::vector<float> > > &
get_3d_rw() {
return data; };
63 std::vector< std::vector< std::vector<float> > >
const &
get_3d()
const {
return data; };
68 std::cout <<
"DataChunk2D " << data.size() <<
"x" << data[0].size() <<
"x" << data[0][0].size() << std::endl;
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] <<
" ";
79 std::cout << std::endl;
88 std::vector<std::vector<std::vector<float> > >
data;
101 std::vector<float>
f;
103 std::vector<float>
const &
get_1d()
const {
return f; }
108 std::cout <<
"DataChunkFlat " << f.size() << std::endl;
111 std::cout <<
"DataChunkFlat values:" << std::endl;
112 for(
size_t i = 0; i < f.size(); ++i) std::cout << f[i] <<
" ";
113 std::cout << std::endl;
121 virtual void load_weights(std::ifstream &
fin) = 0;
124 Layer(std::string name) : m_name(name) {}
127 virtual unsigned int get_input_rows()
const = 0;
128 virtual unsigned int get_input_cols()
const = 0;
129 virtual unsigned int get_output_units()
const = 0;
152 void load_weights(std::ifstream &
fin);
167 void load_weights(std::ifstream &
fin);
181 void load_weights(std::ifstream &
fin);
183 std::vector<std::vector<std::vector<std::vector<float> > > >
m_kernels;
201 void load_weights(std::ifstream &
fin);
220 unsigned int get_input_rows()
const {
return m_layers.front()->get_input_rows(); }
221 unsigned int get_input_cols()
const {
return m_layers.front()->get_input_cols(); }
222 int get_output_length()
const;
226 void load_weights(
const std::string &input_fname);
virtual unsigned int get_output_units() const
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)
virtual unsigned int get_output_units() const
std::vector< std::vector< std::vector< std::vector< float > > > > m_kernels
virtual unsigned int get_input_rows() const
std::vector< std::vector< std::vector< float > > > const & get_3d() const
DataChunk2D(size_t depth, size_t rows, size_t cols, float init)
virtual void read_from_file(const std::string &fname)
virtual unsigned int get_input_cols() const
virtual void set_data(std::vector< std::vector< std::vector< float > > > const &)
unsigned int get_input_cols() const
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
virtual size_t get_data_dim(void) const
size_t get_data_dim(void) const
virtual void show_values()=0
std::vector< std::vector< float > > m_weights
virtual unsigned int get_output_units() const
virtual unsigned int get_output_units() const
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< float > m_bias
virtual void show_name()=0
virtual void set_data(std::vector< float > const &)
std::string m_activation_type
virtual void set_data(std::vector< std::vector< std::vector< float > > > const &d)
std::string m_border_mode
std::vector< std::vector< std::vector< float > > > & get_3d_rw()
unsigned int get_input_rows() const
void missing_activation_impl(const std::string &act)
void load_weights(std::ifstream &fin)
std::vector< Layer * > m_layers
virtual unsigned int get_input_cols() const
DataChunkFlat(size_t size, float init)
virtual unsigned int get_input_rows() const
std::vector< std::vector< std::vector< float > > > data
virtual unsigned int get_output_units() const
void read_from_file(const std::string &fname)
std::vector< float > const & get_1d() const
std::vector< float > & get_1d_rw()
DataChunkFlat(size_t size)
void set_data(std::vector< float > const &d)
std::vector< float > m_bias
size_t get_data_dim(void) const
virtual unsigned int get_input_rows() const
virtual unsigned int get_input_cols() const
virtual unsigned int get_input_cols() const
virtual unsigned int get_input_rows() const
virtual std::vector< float > const & get_1d() const
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)
virtual unsigned int get_input_cols() const
std::vector< float > read_1d_array(std::ifstream &fin, int cols)
virtual unsigned int get_input_rows() const