class nbla::utils::nnp::Nnp
-
class Nnp
Handle of NNabla format files.
You can create an Nnp object by passing default context as below.
using namespace nbla::utils::nnp; nbla::Context ctx{"cpu", "CpuCachedArray", "0", "default"}; Nnp nnp(ctx);
Suppose we have network.nnp which is previously created. You can add a previously dumped NNabla format file to Nnp object. Nnp will parse the file format and internally store the information such as network architectures, learned parameters and execution settings.
nnp.add("network.nnp");
Suppose a network “net1” is in network.npp. The following line will create a Network object from the nnp file. Network can create a computation graph defined in NNabla format files. The created computation graph can be executed in C++ code. See Network doc for the usage.
shared_ptr<Network> network = nnp.get_network("net1"); ... // Use network here.
Suppose an executor “exe1” is in network.npp. The following line will create a Executor object from NNabla format files. The Executor can also create a computation graph of a network associated with the Executor field in NNabla format files. The Executor provides easier interface to set input, execute the graph, and get output.
shared_ptr<Executor> executor = nnp.get_executor("exe1"); ... // Use executor here.
Public Functions
-
NBLA_API Nnp(const nbla::Context &ctx)
Constructor which sets default context.
- Parameters:
ctx – [in] Default context which overwrites the config in nnp file.
- NBLA_API bool add (const string &filename)
Add nnp|nntxt|h5 file.
- NBLA_API bool add (char *buffer, unsigned int size)
Add nnp on memory.
- NBLA_API vector< string > get_network_names ()
Get Network name list from added files (nnp, nntxt etc.).
- Return values:
A – vector of Network instance names.
- NBLA_API shared_ptr< Network > get_network (const string &name)
Get Network object from added files (nnp, nntxt etc.).
- NBLA_API vector< string > get_executor_names ()
Get Executor name list from added files (nnp, nntxt etc.).
- Return values:
A – vector of Executor instance names.
- NBLA_API shared_ptr< Executor > get_executor (const string &name)
Get Executor object from added file(s).
- NBLA_API vector< string > get_optimizer_names ()
Get Optimizer name list from added files (nnp, nntxt etc.).
- Return values:
A – vector of Optimizer instance names.
- NBLA_API shared_ptr< Optimizer > get_optimizer (const string &name)
Get Optimizer object from added files (nnp, nntxt etc.).
- NBLA_API vector< string > get_monitor_names ()
Get Monitor name list from added files (nnp, nntxt etc.).
- Return values:
A – vector of Monitor instance names.
- NBLA_API shared_ptr< Monitor > get_monitor (const string &name)
Get Monitor object from added files (nnp, nntxt etc.).
- NBLA_API shared_ptr< TrainingConfig > get_training_config ()
Get TrainingConfig object from added files (nnp, nntxt etc.).
- Return values:
A – shared pointer of a TrainingConfig instance.
- NBLA_API vector< pair< string, VariablePtr > > get_parameters ()
Get parameters.
- Return values:
A – vector of string and variable pointer pairs.
- NBLA_API bool save_parameters (const string &filename)
Save parameters.
- Parameters:
name – [in] output binary filename (.protobuf or .h5)
-
NBLA_API Nnp(const nbla::Context &ctx)