提交 cf7c0629 authored 作者: Iban Harlouchet's avatar Iban Harlouchet 提交者: Arnaud Bergeron

testcode for doc/tutorial/adding.txt

上级 955d8807
...@@ -72,7 +72,7 @@ are, however, assigned the theano Type ``dscalar`` in their ``type`` ...@@ -72,7 +72,7 @@ are, however, assigned the theano Type ``dscalar`` in their ``type``
field, as you can see here: field, as you can see here:
>>> type(x) >>> type(x)
<class 'theano.tensor.basic.TensorVariable'> <class 'theano.tensor.var.TensorVariable'>
>>> x.type >>> x.type
TensorType(float64, scalar) TensorType(float64, scalar)
>>> T.dscalar >>> T.dscalar
...@@ -201,14 +201,19 @@ with NumPy arrays may be found here: :ref:`tensor creation<libdoc_tensor_creatio ...@@ -201,14 +201,19 @@ with NumPy arrays may be found here: :ref:`tensor creation<libdoc_tensor_creatio
Exercise Exercise
======== ========
.. code-block:: python .. testcode::
import theano
a = theano.tensor.vector() # declare variable
out = a + a ** 10 # build symbolic expression
f = theano.function([a], out) # compile function
print f([0, 1, 2])
.. testoutput::
[ 0. 2. 1026.]
import theano
a = theano.tensor.vector() # declare variable
out = a + a ** 10 # build symbolic expression
f = theano.function([a], out) # compile function
print f([0, 1, 2]) # prints `array([0, 2, 1026])`
Modify and execute this code to compute this expression: a ** 2 + b ** 2 + 2 * a * b. Modify and execute this code to compute this expression: a ** 2 + b ** 2 + 2 * a * b.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论