Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
bob
bob.learn.em
Commits
61cc2540
Commit
61cc2540
authored
Jul 01, 2015
by
Tiago de Freitas Pereira
Browse files
Fixed bug related to the issue
#7
parent
b35b293e
Changes
2
Hide whitespace changes
Inline
Side-by-side
bob/learn/em/test/test_ztnorm.py
View file @
61cc2540
...
...
@@ -80,12 +80,12 @@ def test_ztnorm_big():
assert
(
abs
(
scores
-
ref_scores
)
<
1e-7
).
all
()
# T-Norm
scores
=
tnorm
(
my_A
,
my_C
)
scores
=
bob
.
learn
.
em
.
tnorm
(
my_A
,
my_C
)
scores_py
=
tnorm
(
my_A
,
my_C
)
assert
(
abs
(
scores
-
scores_py
)
<
1e-7
).
all
()
# Z-Norm
scores
=
znorm
(
my_A
,
my_B
)
scores
=
bob
.
learn
.
em
.
znorm
(
my_A
,
my_B
)
scores_py
=
znorm
(
my_A
,
my_B
)
assert
(
abs
(
scores
-
scores_py
)
<
1e-7
).
all
()
...
...
@@ -97,7 +97,7 @@ def test_tnorm_simple():
# 2x5
my_C
=
numpy
.
array
([[
5
,
4
,
3
,
2
,
1
],[
2
,
1
,
2
,
3
,
4
]],
'float64'
)
zC
=
tnorm
(
my_A
,
my_C
)
zC
=
bob
.
learn
.
em
.
tnorm
(
my_A
,
my_C
)
zC_py
=
tnorm
(
my_A
,
my_C
)
assert
(
abs
(
zC
-
zC_py
)
<
1e-7
).
all
()
...
...
@@ -113,7 +113,7 @@ def test_znorm_simple():
# 3x4
my_B
=
numpy
.
array
([[
5
,
4
,
7
,
8
],[
9
,
8
,
7
,
4
],[
5
,
6
,
3
,
2
]],
numpy
.
float64
)
zA
=
znorm
(
my_A
,
my_B
)
zA
=
bob
.
learn
.
em
.
znorm
(
my_A
,
my_B
)
zA_py
=
znorm
(
my_A
,
my_B
)
assert
(
abs
(
zA
-
zA_py
)
<
1e-7
).
all
()
...
...
bob/learn/em/ztnorm.cpp
View file @
61cc2540
...
...
@@ -82,13 +82,13 @@ bob::extension::FunctionDoc t_norm = bob::extension::FunctionDoc(
.
add_return
(
"output"
,
"array_like <float, 2D>"
,
"The scores T Normalized"
);
PyObject
*
PyBobLearnEM_tNorm
(
PyObject
*
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
char
**
kwlist
=
z
t_norm
.
kwlist
(
0
);
char
**
kwlist
=
t_norm
.
kwlist
(
0
);
PyBlitzArrayObject
*
rawscores_probes_vs_models_o
,
*
rawscores_probes_vs_tmodels_o
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O&O&"
,
kwlist
,
&
PyBlitzArray_Converter
,
&
rawscores_probes_vs_models_o
,
&
PyBlitzArray_Converter
,
&
rawscores_probes_vs_tmodels_o
)){
z
t_norm
.
print_usage
();
t_norm
.
print_usage
();
return
0
;
}
...
...
@@ -116,16 +116,16 @@ bob::extension::FunctionDoc z_norm = bob::extension::FunctionDoc(
.
add_prototype
(
"rawscores_probes_vs_models,rawscores_zprobes_vs_models"
,
"output"
)
.
add_parameter
(
"rawscores_probes_vs_models"
,
"array_like <float, 2D>"
,
"Raw set of scores"
)
.
add_parameter
(
"rawscores_zprobes_vs_models"
,
"array_like <float, 2D>"
,
"Z-Scores (raw scores of the Z probes against the models)"
)
.
add_return
(
"output"
,
"array_like <float, 2D>"
,
"The scores
T
Normalized"
);
.
add_return
(
"output"
,
"array_like <float, 2D>"
,
"The scores
Z
Normalized"
);
PyObject
*
PyBobLearnEM_zNorm
(
PyObject
*
,
PyObject
*
args
,
PyObject
*
kwargs
)
{
char
**
kwlist
=
z
t
_norm
.
kwlist
(
0
);
char
**
kwlist
=
z_norm
.
kwlist
(
0
);
PyBlitzArrayObject
*
rawscores_probes_vs_models_o
,
*
rawscores_zprobes_vs_models_o
;
if
(
!
PyArg_ParseTupleAndKeywords
(
args
,
kwargs
,
"O&O&"
,
kwlist
,
&
PyBlitzArray_Converter
,
&
rawscores_probes_vs_models_o
,
&
PyBlitzArray_Converter
,
&
rawscores_zprobes_vs_models_o
)){
z
t
_norm
.
print_usage
();
z_norm
.
print_usage
();
return
0
;
}
...
...
@@ -135,7 +135,6 @@ PyObject* PyBobLearnEM_zNorm(PyObject*, PyObject* args, PyObject* kwargs) {
blitz
::
Array
<
double
,
2
>
rawscores_probes_vs_models
=
*
PyBlitzArrayCxx_AsBlitz
<
double
,
2
>
(
rawscores_probes_vs_models_o
);
blitz
::
Array
<
double
,
2
>
normalized_scores
=
blitz
::
Array
<
double
,
2
>
(
rawscores_probes_vs_models
.
extent
(
0
),
rawscores_probes_vs_models
.
extent
(
1
));
bob
::
learn
::
em
::
zNorm
(
*
PyBlitzArrayCxx_AsBlitz
<
double
,
2
>
(
rawscores_probes_vs_models_o
),
*
PyBlitzArrayCxx_AsBlitz
<
double
,
2
>
(
rawscores_zprobes_vs_models_o
),
normalized_scores
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment