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.Machine
object.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
o
is aPyBobLearnMLPMachineObject
. Returns1
if it is, and0
otherwise.
Cost¶
-
type
PyBobLearnCostObject
¶ 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;
-
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
o
is aPyBobLearnCostObject
. Returns1
if it is, and0
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.
Data Shuffler¶
-
type
PyBobLearnDataShufflerObject
¶ The pythonic representation for a
bob.learn.mlp.DataShuffler
object.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
o
is aPyBobLearnDataShufflerObject
. Returns1
if it is, and0
otherwise.
Trainers¶
-
type
PyBobLearnMLPTrainerObject
¶ 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;
-
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
o
is aPyBobLearnMLPTrainerObject
. Returns1
if it is, and0
otherwise.
-
type
PyBobLearnBackPropObject
¶ 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;
-
PyBobLearnMLPTrainerObject
parent
¶ The parent abstract class pointer. Use
parent.cxx
to 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
o
is aPyBobLearnBackPropObject
. Returns1
if it is, and0
otherwise.
-
type
PyBobLearnRPropObject
¶ 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;
-
PyBobLearnMLPTrainerObject
parent
¶ The parent abstract class pointer. Use
parent.cxx
to 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
o
is aPyBobLearnRPropObject
. Returns1
if it is, and0
otherwise.
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.
Todo
Describe the C++ API of this package.