提交 1cb731e4 authored 作者: hantek's avatar hantek

sloving test failures

上级 1d017d25
...@@ -350,7 +350,7 @@ Example: Op definition ...@@ -350,7 +350,7 @@ Example: Op definition
return eval_points return eval_points
return self.grad(inputs, eval_points) return self.grad(inputs, eval_points)
doubleOp2 = DoubleOp2() doubleOp2 = DoubleOp2()
At a high level, the code fragment declares a class (e.g., ``DoubleOp1``) and then At a high level, the code fragment declares a class (e.g., ``DoubleOp1``) and then
creates one instance of it (e.g., ``doubleOp1``). creates one instance of it (e.g., ``doubleOp1``).
...@@ -412,8 +412,9 @@ but it must not influence the semantics of the Op output. ...@@ -412,8 +412,9 @@ but it must not influence the semantics of the Op output.
You can try the new Op as follows: You can try the new Op as follows:
.. testcode:: example(Using make_node) .. testcode:: example
import theano
x = theano.tensor.matrix() x = theano.tensor.matrix()
f = theano.function([x], DoubleOp1()(x)) f = theano.function([x], DoubleOp1()(x))
import numpy import numpy
...@@ -427,9 +428,6 @@ You can try the new Op as follows: ...@@ -427,9 +428,6 @@ You can try the new Op as follows:
:hide: :hide:
:options: +ELLIPSIS :options: +ELLIPSIS
...
...
.. code-block:: none .. code-block:: none
[[ 0.08257206 0.34308357 0.5288043 0.06582951] [[ 0.08257206 0.34308357 0.5288043 0.06582951]
...@@ -443,8 +441,9 @@ You can try the new Op as follows: ...@@ -443,8 +441,9 @@ You can try the new Op as follows:
[ 1.5465443 1.30803715 1.53125983 1.88291403] [ 1.5465443 1.30803715 1.53125983 1.88291403]
[ 1.6904152 0.61000201 1.76861002 1.9163731 ]] [ 1.6904152 0.61000201 1.76861002 1.9163731 ]]
.. testcode:: example (Using itypes and otypes) .. testcode:: example
import theano
x = theano.tensor.matrix() x = theano.tensor.matrix()
f = theano.function([x], DoubleOp2()(x)) f = theano.function([x], DoubleOp2()(x))
import numpy import numpy
...@@ -459,9 +458,6 @@ You can try the new Op as follows: ...@@ -459,9 +458,6 @@ You can try the new Op as follows:
:hide: :hide:
:options: +ELLIPSIS :options: +ELLIPSIS
...
...
.. code-block:: none .. code-block:: none
[[ 0.02443785 0.67833979 0.91954769 0.95444365] [[ 0.02443785 0.67833979 0.91954769 0.95444365]
...@@ -503,8 +499,8 @@ and ``b`` are equal. ...@@ -503,8 +499,8 @@ and ``b`` are equal.
def make_node(self, x): def make_node(self, x):
# check that the theano version has support for __props__. # check that the theano version has support for __props__.
assert hasattr(self, '_props'), "Your version of theano is too old assert hasattr(self, '_props'), ("Your version of theano is too"
to support __props__." "old to support __props__.")
x = theano.tensor.as_tensor_variable(x) x = theano.tensor.as_tensor_variable(x)
return theano.Apply(self, [x], [x.type()]) return theano.Apply(self, [x], [x.type()])
......
...@@ -116,7 +116,7 @@ one. You can do it like this: ...@@ -116,7 +116,7 @@ one. You can do it like this:
>>> from theano import function >>> from theano import function
>>> x, y = T.dscalars('x', 'y') >>> x, y = T.dscalars('x', 'y')
>>> z = x + y >>> z = x + y
>>> f = function([x, In(y, default=1)], z) >>> f = function([x, In(y, value=1)], z)
>>> f(33) >>> f(33)
array(34.0) array(34.0)
>>> f(33, 2) >>> f(33, 2)
...@@ -125,7 +125,7 @@ array(35.0) ...@@ -125,7 +125,7 @@ array(35.0)
This makes use of the :ref:`In <function_inputs>` class which allows This makes use of the :ref:`In <function_inputs>` class which allows
you to specify properties of your function's parameters with greater detail. Here we you to specify properties of your function's parameters with greater detail. Here we
give a default value of 1 for *y* by creating a ``In`` instance with give a default value of 1 for *y* by creating a ``In`` instance with
its ``default`` field set to 1. its ``value`` field set to 1.
Inputs with default values must follow inputs without default Inputs with default values must follow inputs without default
values (like Python's functions). There can be multiple inputs with default values. These parameters can values (like Python's functions). There can be multiple inputs with default values. These parameters can
...@@ -137,7 +137,7 @@ be set positionally or by name, as in standard Python: ...@@ -137,7 +137,7 @@ be set positionally or by name, as in standard Python:
>>> x, y, w = T.dscalars('x', 'y', 'w') >>> x, y, w = T.dscalars('x', 'y', 'w')
>>> z = (x + y) * w >>> z = (x + y) * w
>>> f = function([x, In(y, default=1), In(w, default=2, name='w_by_name')], z) >>> f = function([x, In(y, value=1), In(w, value=2, name='w_by_name')], z)
>>> f(33) >>> f(33)
array(68.0) array(68.0)
>>> f(33, 2) >>> f(33, 2)
...@@ -154,8 +154,8 @@ array(33.0) ...@@ -154,8 +154,8 @@ array(33.0)
that are passed as arguments. The symbolic variable objects have name that are passed as arguments. The symbolic variable objects have name
attributes (set by ``dscalars`` in the example above) and *these* are the attributes (set by ``dscalars`` in the example above) and *these* are the
names of the keyword parameters in the functions that we build. This is names of the keyword parameters in the functions that we build. This is
the mechanism at work in ``In(y, default=1)``. In the case of ``In(w, the mechanism at work in ``In(y, value=1)``. In the case of ``In(w,
default=2, name='w_by_name')``. We override the symbolic variable's name value=2, name='w_by_name')``. We override the symbolic variable's name
attribute with a name to be used for this function. attribute with a name to be used for this function.
......
...@@ -33,7 +33,7 @@ functions using either of the following two options: ...@@ -33,7 +33,7 @@ functions using either of the following two options:
- You can also combine the profile of many functions: - You can also combine the profile of many functions:
.. testcode:: .. testcode::
:hide:
profile = theano.compile.ProfileStats() profile = theano.compile.ProfileStats()
f = theano.function(..., profile=profile) f = theano.function(..., profile=profile)
g = theano.function(..., profile=profile) g = theano.function(..., profile=profile)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论