Skip to content
Snippets Groups Projects
Commit fc57a620 authored by Tiago de Freitas Pereira's avatar Tiago de Freitas Pereira
Browse files

[sphinx] Fixed doc test

parent 9359106c
No related branches found
No related tags found
No related merge requests found
Pipeline #
...@@ -39,16 +39,15 @@ in double-precision. Here is how to use a ...@@ -39,16 +39,15 @@ in double-precision. Here is how to use a
.. doctest:: .. doctest::
>>> W = numpy.array([[0.5, 0.5], [1.0, 1.0]], 'float64') >>> W = numpy.array([[0.5, 0.5], [1.0, 1.0]], 'float64')
>>> W >>> numpy.allclose(W, [[ 0.5, 0.5], [ 1. , 1. ]])
array([[ 0.5, 0.5], True
[ 1. , 1. ]])
>>> machine = bob.learn.linear.Machine(W) >>> machine = bob.learn.linear.Machine(W)
>>> machine.shape >>> machine.shape
(2, 2) (2, 2)
>>> x = numpy.array([0.3, 0.4], 'float64') >>> x = numpy.array([0.3, 0.4], 'float64')
>>> y = machine(x) >>> y = machine(x)
>>> y >>> numpy.allclose(y, [ 0.55, 0.55])
array([ 0.55, 0.55]) True
As was shown in the above example, the way to pass data through a machine is to As was shown in the above example, the way to pass data through a machine is to
call its :py:meth:`bob.learn.linear.Machine.forward` method, for which the call its :py:meth:`bob.learn.linear.Machine.forward` method, for which the
...@@ -97,10 +96,10 @@ division. By default, :math:`s := 0.0` and :math:`d := 1.0`. ...@@ -97,10 +96,10 @@ division. By default, :math:`s := 0.0` and :math:`d := 1.0`.
.. doctest:: .. doctest::
>>> machine.input_subtract >>> numpy.allclose(machine.input_subtract, [ 0., 0.])
array([ 0., 0.]) True
>>> machine.input_divide >>> numpy.allclose(machine.input_divide, [ 1., 1.])
array([ 1., 1.]) True
To set a new value for :math:`s` or :math:`d` just assign the desired machine To set a new value for :math:`s` or :math:`d` just assign the desired machine
property: property:
...@@ -171,7 +170,7 @@ Next, input data can be projected using this learned projection matrix ...@@ -171,7 +170,7 @@ Next, input data can be projected using this learned projection matrix
>>> e = numpy.array([3.2,-3.3,-10], 'float64') >>> e = numpy.array([3.2,-3.3,-10], 'float64')
>>> print(machine(e)) >>> print(machine(e))
[ 9.999 0.47 0.092] [9.999 0.47 0.092]
Linear discriminant analysis Linear discriminant analysis
...@@ -204,11 +203,12 @@ for **PCA**. This is shown below. ...@@ -204,11 +203,12 @@ for **PCA**. This is shown below.
>>> print(eig_vals) # doctest: +SKIP >>> print(eig_vals) # doctest: +SKIP
[ 13.10097786 0. ] [ 13.10097786 0. ]
>>> machine.resize(3,1) # Make the output space of dimension 1 >>> machine.resize(3,1) # Make the output space of dimension 1
>>> print(machine.weights) # The new weights after the training procedure >>> print(machine.weights) # The new weights after the training procedure
[[ 0.609] [[0.609]
[ 0.785] [0.785]
[ 0.111]] [0.111]]
Whitening Whitening
========== ==========
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment