Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
bob.learn.em
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
bob
bob.learn.em
Commits
e530ba1f
Commit
e530ba1f
authored
10 years ago
by
Tiago de Freitas Pereira
Browse files
Options
Downloads
Patches
Plain Diff
Started the binding
parent
c9f8ab18
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
bob/learn/misc/kmeans_trainer.cpp
+25
-17
25 additions, 17 deletions
bob/learn/misc/kmeans_trainer.cpp
bob/learn/misc/main.h
+1
-1
1 addition, 1 deletion
bob/learn/misc/main.h
setup.py
+1
-0
1 addition, 0 deletions
setup.py
with
27 additions
and
18 deletions
bob/learn/misc/kmeans_trainer.cpp
+
25
−
17
View file @
e530ba1f
...
@@ -13,12 +13,13 @@
...
@@ -13,12 +13,13 @@
/************ Constructor Section *********************************/
/************ Constructor Section *********************************/
/******************************************************************/
/******************************************************************/
static
auto
KMeansTrainer_doc
=
bob
::
extension
::
ClassDoc
(
static
auto
KMeansTrainer_doc
=
bob
::
extension
::
ClassDoc
(
BOB_EXT_MODULE_PREFIX
".KMeansTrainer"
,
BOB_EXT_MODULE_PREFIX
".KMeansTrainer"
,
"Trains a KMeans machine.
\n
"
"Trains a KMeans machine."
"This class implements the expectation-maximization algorithm for a k-means machine.
\n
"
"This class implements the expectation-maximization algorithm for a k-means machine."
"See Section 9.1 of Bishop,
\"
Pattern recognition and machine learning
\"
, 2006
\n
"
"See Section 9.1 of Bishop,
\"
Pattern recognition and machine learning
\"
, 2006"
"It uses a random initialization of the means followed by the expectation-maximization algorithm"
,
"It uses a random initialization of the means followed by the expectation-maximization algorithm"
).
add_constructor
(
).
add_constructor
(
bob
::
extension
::
FunctionDoc
(
bob
::
extension
::
FunctionDoc
(
"__init__"
,
"__init__"
,
...
@@ -36,33 +37,41 @@ static auto KMeansTrainer_doc = bob::extension::ClassDoc(
...
@@ -36,33 +37,41 @@ static auto KMeansTrainer_doc = bob::extension::ClassDoc(
);
);
static
int
PyBobLearnMiscKMeansTrainer_init_copy
(
PyBobLearnMiscKMeans
Mach
ineObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
static
int
PyBobLearnMiscKMeansTrainer_init_copy
(
PyBobLearnMiscKMeans
Tra
ine
r
Object
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
char
**
kwlist
=
KMeans
Mach
ine_doc
.
kwlist
(
1
);
char
**
kwlist
=
KMeans
Tra
ine
r
_doc
.
kwlist
(
1
);
PyBobLearnMiscKMeans
Mach
ineObject
*
tt
;
PyBobLearnMiscKMeans
Tra
ine
r
Object
*
tt
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O!"
,
kwlist
,
&
PyBobLearnMiscKMeans
Mach
ine_Type
,
&
tt
)){
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O!"
,
kwlist
,
&
PyBobLearnMiscKMeans
Tra
ine
r
_Type
,
&
tt
)){
KMeans
Mach
ine_doc
.
print_usage
();
KMeans
Tra
ine
r
_doc
.
print_usage
();
return
-
1
;
return
-
1
;
}
}
self
->
cxx
.
reset
(
new
bob
::
learn
::
misc
::
KMeans
Mach
ine
(
*
tt
->
cxx
));
self
->
cxx
.
reset
(
new
bob
::
learn
::
misc
::
KMeans
Tra
ine
r
(
*
tt
->
cxx
));
return
0
;
return
0
;
}
}
static
int
PyBobLearnMiscKMeansTrainer_init
(
PyBobLearnMiscKMeansTrainerObject
*
self
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
BOB_TRY
// get the number of command line arguments
//int nargs = (args?PyTuple_Size(args):0) + (kwargs?PyDict_Size(kwargs):0);
BOB_CATCH_MEMBER
(
"cannot create KMeansTrainer"
,
0
)
return
0
;
}
static
void
PyBobLearnMiscKMeans
Mach
ine_delete
(
PyBobLearnMiscKMeans
Mach
ineObject
*
self
)
{
static
void
PyBobLearnMiscKMeans
Tra
ine
r
_delete
(
PyBobLearnMiscKMeans
Tra
ine
r
Object
*
self
)
{
self
->
cxx
.
reset
();
self
->
cxx
.
reset
();
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
Py_TYPE
(
self
)
->
tp_free
((
PyObject
*
)
self
);
}
}
int
PyBobLearnMiscKMeans
Mach
ine_Check
(
PyObject
*
o
)
{
int
PyBobLearnMiscKMeans
Tra
ine
r
_Check
(
PyObject
*
o
)
{
return
PyObject_IsInstance
(
o
,
reinterpret_cast
<
PyObject
*>
(
&
PyBobLearnMiscKMeans
Mach
ine_Type
));
return
PyObject_IsInstance
(
o
,
reinterpret_cast
<
PyObject
*>
(
&
PyBobLearnMiscKMeans
Tra
ine
r
_Type
));
}
}
/******************************************************************/
/******************************************************************/
/************ Variables Section ***********************************/
/************ Variables Section ***********************************/
/******************************************************************/
/******************************************************************/
...
@@ -80,7 +89,6 @@ static PyGetSetDef PyBobLearnMiscKMeansTrainer_getseters[] = {
...
@@ -80,7 +89,6 @@ static PyGetSetDef PyBobLearnMiscKMeansTrainer_getseters[] = {
static
PyMethodDef
PyBobLearnMiscKMeansTrainer_methods
[]
=
{
static
PyMethodDef
PyBobLearnMiscKMeansTrainer_methods
[]
=
{
{
0
}
/* Sentinel */
{
0
}
/* Sentinel */
};
};
...
@@ -107,7 +115,7 @@ bool init_BobLearnMiscKMeansTrainer(PyObject* module)
...
@@ -107,7 +115,7 @@ bool init_BobLearnMiscKMeansTrainer(PyObject* module)
// set the functions
// set the functions
PyBobLearnMiscKMeansTrainer_Type
.
tp_new
=
PyType_GenericNew
;
PyBobLearnMiscKMeansTrainer_Type
.
tp_new
=
PyType_GenericNew
;
PyBobLearnMiscKMeansTrainer_Type
.
tp_init
=
reinterpret_cast
<
initproc
>
(
PyBobLearnMiscKMeansTrainer_init
);
PyBobLearnMiscKMeansTrainer_Type
.
tp_init
=
reinterpret_cast
<
initproc
>
(
PyBobLearnMiscKMeansTrainer_init
);
PyBobLearnMiscKMeansTrainer_Type
.
tp_dealloc
=
reinterpret_cast
<
destructor
>
(
PyBobLearnMiscKTrainer_delete
);
PyBobLearnMiscKMeansTrainer_Type
.
tp_dealloc
=
reinterpret_cast
<
destructor
>
(
PyBobLearnMiscK
Means
Trainer_delete
);
//PyBobLearnMiscKMeansTrainer_Type.tp_richcompare = reinterpret_cast<richcmpfunc>(PyBobLearnMiscKMeansTrainer_RichCompare);
//PyBobLearnMiscKMeansTrainer_Type.tp_richcompare = reinterpret_cast<richcmpfunc>(PyBobLearnMiscKMeansTrainer_RichCompare);
PyBobLearnMiscKMeansTrainer_Type
.
tp_methods
=
PyBobLearnMiscKMeansTrainer_methods
;
PyBobLearnMiscKMeansTrainer_Type
.
tp_methods
=
PyBobLearnMiscKMeansTrainer_methods
;
PyBobLearnMiscKMeansTrainer_Type
.
tp_getset
=
PyBobLearnMiscKMeansTrainer_getseters
;
PyBobLearnMiscKMeansTrainer_Type
.
tp_getset
=
PyBobLearnMiscKMeansTrainer_getseters
;
...
@@ -119,6 +127,6 @@ bool init_BobLearnMiscKMeansTrainer(PyObject* module)
...
@@ -119,6 +127,6 @@ bool init_BobLearnMiscKMeansTrainer(PyObject* module)
// add the type to the module
// add the type to the module
Py_INCREF
(
&
PyBobLearnMiscKMeansTrainer_Type
);
Py_INCREF
(
&
PyBobLearnMiscKMeansTrainer_Type
);
return
PyModule_AddObject
(
module
,
"
_
KMeansTrainer"
,
(
PyObject
*
)
&
PyBobLearnMiscKMeansTrainer_Type
)
>=
0
;
return
PyModule_AddObject
(
module
,
"KMeansTrainer"
,
(
PyObject
*
)
&
PyBobLearnMiscKMeansTrainer_Type
)
>=
0
;
}
}
This diff is collapsed.
Click to expand it.
bob/learn/misc/main.h
+
1
−
1
View file @
e530ba1f
...
@@ -21,7 +21,7 @@
...
@@ -21,7 +21,7 @@
#include
<bob.learn.misc/GMMStats.h>
#include
<bob.learn.misc/GMMStats.h>
#include
<bob.learn.misc/GMMMachine.h>
#include
<bob.learn.misc/GMMMachine.h>
#include
<bob.learn.misc/KMeansMachine.h>
#include
<bob.learn.misc/KMeansMachine.h>
#include
<bob.learn.misc/KMeansTrainer.h>
#if PY_VERSION_HEX >= 0x03000000
#if PY_VERSION_HEX >= 0x03000000
#define PyInt_Check PyLong_Check
#define PyInt_Check PyLong_Check
...
...
This diff is collapsed.
Click to expand it.
setup.py
+
1
−
0
View file @
e530ba1f
...
@@ -104,6 +104,7 @@ setup(
...
@@ -104,6 +104,7 @@ setup(
"
bob/learn/misc/gmm_stats.cpp
"
,
"
bob/learn/misc/gmm_stats.cpp
"
,
"
bob/learn/misc/gmm_machine.cpp
"
,
"
bob/learn/misc/gmm_machine.cpp
"
,
"
bob/learn/misc/kmeans_machine.cpp
"
,
"
bob/learn/misc/kmeans_machine.cpp
"
,
"
bob/learn/misc/kmeans_trainer.cpp
"
,
"
bob/learn/misc/main.cpp
"
,
"
bob/learn/misc/main.cpp
"
,
],
],
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment