The C++ API of bob.learn.mlp allows users to leverage from automatic converters for classes in bob.learn.mlp. To use the C API, clients should first, include the header file <bob.learn.mlp.h> on their compilation units and then, make sure to call once import_bob_learn_mlp() at their module instantiation, as explained at the Python manual.
Here is a dummy C example showing how to include the header and where to call the import function:
#include <bob.learn.mlp/api.h>
PyMODINIT_FUNC initclient(void) {
PyObject* m Py_InitModule("client", ClientMethods);
if (!m) return 0;
if (import_bob_blitz() < 0) return 0;
if (import_bob_io() < 0) return 0;
if (import_bob_learn_activation() < 0) return 0;
if (import_bob_learn_mlp() < 0) return 0;
return m;
}
Note
The include directory can be discovered using bob.learn.mlp.get_include().
The pythonic object representation for a bob.learn.mlp.Machine object.
typedef struct {
PyObject_HEAD
bob::learn::mlp::Machine* cxx;
} PyBobLearnMLPMachineObject;
A pointer to the machine implentation in C++.
Checks if the input object o is a PyBobLearnMLPMachineObject. Returns 1 if it is, and 0 otherwise.
The pythonic object representation for a bob.learn.mlp.Cost object. It is the base class of all derive cost types available in Bob.
typedef struct {
PyObject_HEAD
boost::shared_ptr<bob::learn::mlp::Cost> cxx;
} PyBobLearnCostObject;
A pointer to the cost object implemented in C++. The cost object is an abstract interface. You cannot instantiate a cost from scratch, but only through its inherited classes.
We use a boost shared pointer to hold this pointer since it makes interaction with the C++ library and the management of responsibilities a bit easier.
Checks if the input object o is a PyBobLearnCostObject. Returns 1 if it is, and 0 otherwise.
Note
These are the cost object specializations you can use from Python:
For each of those types, object types in C exist.
Builds a new cost object from a shared pointer to the C++ equivalent.
Returns the object on success or a NULL pointer on failure.
The pythonic representation for a bob.learn.mlp.DataShuffler object.
typedef struct {
PyObject_HEAD
bob::learn::mlp::DataShuffler* cxx;
} PyBobLearnCostObject;
A pointer to the data shuffler object implemented in C++.
Checks if the input object o is a PyBobLearnDataShufflerObject. Returns 1 if it is, and 0 otherwise.
The pythonic representation for a bob.learn.mlp.Trainer object. All back-propagation-based trainers should inherit from this type as it implements most of the basic functionality needed by such a learning technique.
typedef struct {
PyObject_HEAD
bob::learn::mlp::Trainer* cxx;
} PyBobLearnCostObject;
A pointer to the base trainer object implemented in C++.
Checks if the input object o is a PyBobLearnMLPTrainerObject. Returns 1 if it is, and 0 otherwise.
The pythonic representation for a bob.learn.mlp.BackProp object. All back-propagation-based trainers should inherit from this type as it implements most of the basic functionality needed by such a learning technique.
typedef struct {
PyBobLearnMLPTrainerObject parent;
bob::learn::mlp::BackProp* cxx;
} PyBobLearnCostObject;
The parent abstract class pointer. Use parent.cxx to access the abstract C++ base interface.
A pointer to the derived trainer object implemented in C++.
Checks if the input object o is a PyBobLearnBackPropObject. Returns 1 if it is, and 0 otherwise.
The pythonic representation for a bob.learn.mlp.RProp object. All back-propagation-based trainers should inherit from this type as it implements most of the basic functionality needed by such a learning technique.
typedef struct {
PyBobLearnMLPTrainerObject parent;
bob::learn::mlp::RProp* cxx;
} PyBobLearnCostObject;
The parent abstract class pointer. Use parent.cxx to access the abstract C++ base interface.
A pointer to the derived trainer object implemented in C++.
Checks if the input object o is a PyBobLearnRPropObject. Returns 1 if it is, and 0 otherwise.
As explained above, each PyObject produced by this library contains a pointer to a pure C++ implementation of a similar object. The C++ of such objects is described in this section.
Todo
Describe the C++ API of this package.