12 #ifndef KERAS_MODEL__H 13 #define KERAS_MODEL__H 48 virtual std::vector<float>
const&
get_1d()
const {
throw "not implemented"; };
49 virtual std::vector<std::vector<std::vector<float>>>
const&
get_3d()
const 51 throw "not implemented";
54 virtual void set_data(std::vector<float>
const&){};
63 DataChunk2D(
size_t depth,
size_t rows,
size_t cols,
float init)
68 std::vector<std::vector<std::vector<float>>>&
get_3d_rw() {
return data; };
69 std::vector<std::vector<std::vector<float>>>
const&
get_3d()
const {
return data; };
75 std::cout <<
"DataChunk2D " << data.size() <<
"x" << data[0].size() <<
"x" << data[0][0].size()
81 std::cout <<
"DataChunk2D values:" << std::endl;
82 for (
size_t i = 0; i < data.size(); ++i) {
83 std::cout <<
"Kernel " << i << std::endl;
84 for (
size_t j = 0; j < data[0].size(); ++j) {
85 for (
size_t k = 0; k < data[0][0].size(); ++k) {
86 std::cout << data[i][j][k] <<
" ";
88 std::cout << std::endl;
97 std::vector<std::vector<std::vector<float>>>
data;
110 std::vector<float>
f;
112 std::vector<float>
const&
get_1d()
const {
return f; }
116 void show_name() { std::cout <<
"DataChunkFlat " << f.size() << std::endl; }
119 std::cout <<
"DataChunkFlat values:" << std::endl;
120 for (
size_t i = 0; i < f.size(); ++i)
121 std::cout << f[i] <<
" ";
122 std::cout << std::endl;
130 virtual void load_weights(std::ifstream&
fin) = 0;
133 Layer(std::string name) : m_name(name) {}
136 virtual unsigned int get_input_rows()
const = 0;
137 virtual unsigned int get_input_cols()
const = 0;
138 virtual unsigned int get_output_units()
const = 0;
162 void load_weights(std::ifstream&
fin);
179 void load_weights(std::ifstream&
fin);
196 void load_weights(std::ifstream&
fin);
198 std::vector<std::vector<std::vector<std::vector<float>>>>
m_kernels;
216 void load_weights(std::ifstream&
fin);
235 unsigned int get_input_rows()
const {
return m_layers.front()->get_input_rows(); }
236 unsigned int get_input_cols()
const {
return m_layers.front()->get_input_cols(); }
237 int get_output_length()
const;
240 void load_weights(
const std::string& input_fname);
virtual unsigned int get_output_units() const
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
DataChunk2D(size_t depth, size_t rows, size_t cols, float init)
virtual void set_data(std::vector< std::vector< std::vector< float >>> const &)
virtual void read_from_file(const std::string &fname)
virtual unsigned int get_input_cols() const
std::vector< std::vector< std::vector< float > > > const & get_3d() 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
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_output_units() const
decltype(auto) constexpr size(T &&obj)
ADL-aware version of std::size.
auto vector(Vector const &v)
Returns a manipulator which will print the specified array.
std::vector< float > m_bias
virtual void show_name()=0
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)
std::vector< Layer * > m_layers
virtual void set_data(std::vector< float > const &)
std::string m_activation_type
std::string m_border_mode
unsigned int get_input_rows() const
void missing_activation_impl(const std::string &act)
void load_weights(std::ifstream &fin)
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< std::vector< std::vector< float > > > & get_3d_rw()
std::vector< float > const & get_1d() const
virtual void set_data(std::vector< std::vector< std::vector< float >>> const &d)
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
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