C++ API¶
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;
}
Machine¶
-
type
PyBobLearnMLPMachineObject¶ The pythonic object representation for a
bob.learn.mlp.Machineobject.typedef struct { PyObject_HEAD bob::learn::mlp::Machine* cxx; } PyBobLearnMLPMachineObject;
-
bob::learn::mlp::Machine *
cxx¶ A pointer to the machine implentation in C++.
-
bob::learn::mlp::Machine *
-
int
PyBobLearnMLPMachine_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnMLPMachineObject. Returns1if it is, and0otherwise.
Cost¶
-
type
PyBobLearnCostObject¶ The pythonic object representation for a
bob.learn.mlp.Costobject. 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;
-
boost::shared_ptr<bob::learn::mlp::Cost>
cxx¶ 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.
-
boost::shared_ptr<bob::learn::mlp::Cost>
-
int
PyBobLearnCost_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnCostObject. Returns1if it is, and0otherwise.
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.
Data Shuffler¶
-
type
PyBobLearnDataShufflerObject¶ The pythonic representation for a
bob.learn.mlp.DataShufflerobject.typedef struct { PyObject_HEAD bob::learn::mlp::DataShuffler* cxx; } PyBobLearnCostObject;
-
bob::learn::mlp::DataShuffler *
cxx¶ A pointer to the data shuffler object implemented in C++.
-
bob::learn::mlp::DataShuffler *
-
int
PyBobLearnDataShuffler_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnDataShufflerObject. Returns1if it is, and0otherwise.
Trainers¶
-
type
PyBobLearnMLPTrainerObject¶ The pythonic representation for a
bob.learn.mlp.Trainerobject. 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;
-
bob::learn::mlp::Trainer *
cxx¶ A pointer to the base trainer object implemented in C++.
-
bob::learn::mlp::Trainer *
-
int
PyBobLearnMLPTrainer_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnMLPTrainerObject. Returns1if it is, and0otherwise.
-
type
PyBobLearnBackPropObject¶ The pythonic representation for a
bob.learn.mlp.BackPropobject. 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;
-
PyBobLearnMLPTrainerObject
parent¶ The parent abstract class pointer. Use
parent.cxxto access the abstract C++ base interface.
-
bob::learn::mlp::BackProp *
cxx¶ A pointer to the derived trainer object implemented in C++.
-
PyBobLearnMLPTrainerObject
-
int
PyBobLearnBackProp_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnBackPropObject. Returns1if it is, and0otherwise.
-
type
PyBobLearnRPropObject¶ The pythonic representation for a
bob.learn.mlp.RPropobject. 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;
-
PyBobLearnMLPTrainerObject
parent¶ The parent abstract class pointer. Use
parent.cxxto access the abstract C++ base interface.
-
bob::learn::mlp::RProp *
cxx¶ A pointer to the derived trainer object implemented in C++.
-
PyBobLearnMLPTrainerObject
-
int
PyBobLearnRProp_Check(PyObject *o)¶ Checks if the input object
ois aPyBobLearnRPropObject. Returns1if it is, and0otherwise.
Pure C/C++ API¶
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.