Main Page
Related Pages
Modules
Namespaces
Classes
Files
Examples
File List
File Members
larreco
larreco
RecoAlg
ImagePatternAlgs
Keras
example_main.cc
Go to the documentation of this file.
1
#include "
keras_model.h
"
2
3
#include <iostream>
4
5
using namespace
std
;
6
using namespace
keras
;
7
8
// Step 1
9
// Dump keras model and input sample into text files
10
// python dump_to_simple_cpp.py -a example/my_nn_arch.json -w example/my_nn_weights.h5 -o example/dumped.nnet
11
// Step 2
12
// Use text files in c++ example. To compile:
13
// g++ keras_model.cc example_main.cc
14
// To execute:
15
// a.out
16
17
int
main
() {
18
cout <<
"This is simple example with Keras neural network model loading into C++.\n"
19
<<
"Keras model will be used in C++ for prediction only."
<<
endl
;
20
21
DataChunk
*sample =
new
DataChunk2D
();
22
sample->
read_from_file
(
"./example/sample_mnist.dat"
);
23
std::cout << sample->
get_3d
().size() <<
std::endl
;
24
KerasModel
m
(
"./example/dumped.nnet"
);
25
m.
compute_output
(sample);
26
27
return
0;
28
}
keras_model.h
main
int main()
Definition:
example_main.cc:17
keras::KerasModel
Definition:
keras_model.h:214
keras::DataChunk::read_from_file
virtual void read_from_file(const std::string &fname)
Definition:
keras_model.h:50
std
STL namespace.
keras::DataChunk::get_3d
virtual std::vector< std::vector< std::vector< float > > > const & get_3d() const
Definition:
keras_model.h:46
keras::KerasModel::compute_output
std::vector< float > compute_output(keras::DataChunk *dc)
Definition:
keras_model.cc:400
keras::DataChunk
Definition:
keras_model.h:41
keras
Definition:
keras_model.h:20
cache_state.m
m
Definition:
cache_state.py:388
keras::DataChunk2D
Definition:
keras_model.h:55
endl
QTextStream & endl(QTextStream &s)
Definition:
qtextstream.cpp:2030
Generated by
1.8.11