提交 18fae10e authored 作者: Razvan Pascanu's avatar Razvan Pascanu

add a short how to use shared vars

上级 22931282
......@@ -9,7 +9,17 @@ TensorType
.. class:: TensorType
.. method:: quux()
.. _libdoc_tensor_variable
TensorVariable
==============
.. _libdoc_tensor_constant
TensorConstant
==============
......@@ -155,20 +165,41 @@ bytes, we would do:
my_cmatrix = theano.tensor.TensorType('complex64', [False, False])
Shared Variable
---------------
Yet another way of creating a special type of Theano variable is by using
:func:`shared` as in the example below:
.. code-block:: python
x = shared(value, name)
Shared takes two parameters, `value` and `name` and creates a Theano
variable with the name `name` and initial value `value`. The type of this
variable is obtained from the type of the value `value`, so if value is a
numpy float matrix the shared variable will be of type `fmatrix`.
Note that a shared variable is not like other Theano variables. For more
details of how to use shared variables look :ref:`here <functionstateexample>` (or for more details
:ref:`here <sharedvars>`). TODO : make the last link to a detailed
description of shared variables.
Autocasting
-----------
TODO: What does (or compatible) mean? Talk about casting rules, refer .
Theano does autocasting of numpy ndarray or python floats/ints into
Theano constants.
TODO: What does (or compatible) mean? Talk about casting rules, refer .
TODO: link to floatX (?)
.. function:: as_tensor_variable(x, ...)
.. function:: lvector(name=None)
TODO: make a table of all [scalar, vector, matrix, tensor3, tensor4] vs. [b,
w, i, l, f, d, c, z]
Shaping and Shuffling
......
......@@ -79,7 +79,7 @@ In the example above, there is no way to guarantee that a future call to say,
If you instantiate DebugMode using the constructor ``compile.DebugMode``
rather than the keyword ``DEBUG_MODE`` you can configure its behaviour via
constructor arguments. See :ref:`DebugMode <compile_debugMode>` for details.
constructor arguments. See :ref:`DebugMode <debugMode>` for details.
The keyword version of DebugMode (which you get by using ``mode='DEBUG_MODE``)
is quite strict, and can raise several different Exception types. For a
......
......@@ -48,15 +48,6 @@ d double floating point 64
Dimensionality is one of:
====== ====== ======================================================== ===========================================================
code shape Rows :ref:`broadcastable <libdoc_tensor_broadcastable>`? Columns :ref:`broadcastable <libdoc_tensor_broadcastable>`?
====== ====== ======================================================== ===========================================================
scalar [] Yes Yes
vector [n] Yes N/A (vectors are used like row vectors)
row [1, n] Yes No
col [m, 1] No Yes
matrix [m, n] No No
====== ====== ======================================================== ============================================================
So, if you want a row of 32-bit floats, it is available
as :ref:`theano.tensor.frow <libdoc_tensor_type>`.
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论