Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
92cb4b40
提交
92cb4b40
authored
1月 18, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixing technical stuff in docs
上级
efa9630b
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
182 行增加
和
197 行删除
+182
-197
cop.txt
doc/extending/cop.txt
+16
-14
ctype.txt
doc/extending/ctype.txt
+29
-27
graphstructures.txt
doc/extending/graphstructures.txt
+11
-12
op.txt
doc/extending/op.txt
+2
-4
optimization.txt
doc/extending/optimization.txt
+25
-23
type.txt
doc/extending/type.txt
+42
-40
glossary.txt
doc/glossary.txt
+29
-36
basic.txt
doc/library/tensor/basic.txt
+10
-17
debug_faq.txt
doc/tutorial/debug_faq.txt
+16
-22
symbolic_graphs.txt
doc/tutorial/symbolic_graphs.txt
+2
-2
没有找到文件。
doc/extending/cop.txt
浏览文件 @
92cb4b40
...
...
@@ -26,26 +26,28 @@ What needs to be defined
There are less methods to define for an Op than for a Type:
..
function:: c_code(node, name, input_names, output_names, sub)
..
class:: Op
This must return C code that carries the computation we want to do.
.. method:: c_code(node, name, input_names, output_names, sub)
.. function:: c_code_cleanup(node, name, input_names, output_names, sub)
This must return C code that carries the computation we want to do.
This must return C code that cleans up whatever c_code allocated and
that we must free.
.. method:: c_code_cleanup(node, name, input_names, output_names, sub)
*Default:* The default behavior is to do nothing.
This must return C code that cleans up whatever c_code allocated and
that we must free.
.. function:: c_compile_args()
c_no_compile_args()
c_headers()
c_libraries()
c_support_code()
*Default:* The default behavior is to do nothing.
Allows you to specify headers, libraries,
special g++ arguments to add/exclude or
helper functions/structs that the type needs. See :ref:`op`.
.. method:: c_compile_args()
.. method:: c_no_compile_args()
.. method:: c_headers()
.. method:: c_libraries()
.. method:: c_support_code()
Allows you to specify headers, libraries,
special g++ arguments to add/exclude or
helper functions/structs that the type needs. See :ref:`op`.
The ``name`` argument is currently given an invalid value, so steer
...
...
doc/extending/ctype.txt
浏览文件 @
92cb4b40
...
...
@@ -46,43 +46,45 @@ be found in the documentation for :api:`gof.type.Type`. Here, we'll focus on
the most important ones:
..
function:: c_declare(name, sub)
..
class:: CLinkerType
This must return C code which declares variables. These variables
will be available to operations defined in C. You may also write
typedefs.
.. method:: c_declare(name, sub)
.. function:: c_init(name, sub)
This must return C code which declares variables. These variables
will be available to operations defined in C. You may also write
typedefs.
This must return C code which initializes the variables declared in
``c_declare``. Either this or ``c_extract`` will be called.
.. method:: c_init(name, sub)
.. function:: c_extract(name, sub)
This must return C code which initializes the variables declared in
``c_declare``. Either this or ``c_extract`` will be called.
This must return C code which takes a reference to a Python object
and initializes the variables declared in ``c_declare`` to match the
Python object's data. Either this or ``c_init`` will be called.
.. method:: c_extract(name, sub)
.. function:: c_sync(name, sub)
This must return C code which takes a reference to a Python object
and initializes the variables declared in ``c_declare`` to match the
Python object's data. Either this or ``c_init`` will be called.
When the computations are done, transfer the variables from the C
structure we put them in to the destination Python object. This will
only be called for the outputs.
.. method:: c_sync(name, sub)
.. function:: c_cleanup(name, sub)
When the computations are done, transfer the variables from the C
structure we put them in to the destination Python object. This will
only be called for the outputs.
When we are done using the data, clean up whatever we allocated and
decrease the appropriate reference counts.
.. method:: c_cleanup(name, sub)
.. function:: c_compile_args()
c_no_compile_args()
c_headers()
c_libraries()
c_support_code()
When we are done using the data, clean up whatever we allocated and
decrease the appropriate reference counts.
Allows you to specify headers, libraries,
special g++ arguments to add/exclude or
helper functions/structs that the type needs. See :ref:`type`.
.. method:: c_compile_args()
c_no_compile_args()
c_headers()
c_libraries()
c_support_code()
Allows you to specify headers, libraries,
special g++ arguments to add/exclude or
helper functions/structs that the type needs. See :ref:`type`.
Each of these functions take two arguments, ``name`` and ``sub`` which
...
...
@@ -391,7 +393,7 @@ done. Note which variables get extracted (the three inputs ``x``, ``y`` and
output ``b``) and which one is synced (the final output ``b``).
The C code above is a single C block for the whole graph. Depending on
which :
ref
:`linker` is used to process the computation graph, it is
which :
term
:`linker` is used to process the computation graph, it is
possible that one such block is generated for each operation and that
we transit through Python after each operation. In that situation,
``a`` would be synced by the addition block and extracted by the
...
...
doc/extending/graphstructures.txt
浏览文件 @
92cb4b40
...
...
@@ -146,7 +146,7 @@ Automatic wrapping
All nodes in the graph must be instances of ``Apply`` or ``Result``, but
``<Op subclass>.make_node()`` typically wraps constants to satisfy those
constraints. For example, the :
api:`tensor.add <theano.tensor.basic.add>
`
constraints. For example, the :
func:`tensor.add
`
Op instance is written so that:
.. code-block:: python
...
...
@@ -189,8 +189,8 @@ An *Apply node* is a type of internal node used to represent a
manipulated directly by the end user. They may be accessed via
a Variable's ``owner`` field.
An Apply node is typically an instance of the :
api:`Apply
<theano.gof.graph.Apply>`
class. It represents the application
An Apply node is typically an instance of the :
class:`Apply`
class. It represents the application
of an :ref:`op` on one or more inputs, where each input is a
:ref:`variable`. By convention, each Op is responsible for
knowing how to build an Apply node from a list of
...
...
@@ -215,8 +215,7 @@ An Apply instance has three important fields:
A list of :ref:`Variables <variable>` that represent the return values
of the function.
An Apply instance can be created by calling ``gof.Apply(op, inputs,
outputs)``.
An Apply instance can be created by calling ``gof.Apply(op, inputs, outputs)``.
...
...
@@ -260,7 +259,7 @@ Type
A :ref:`type` in Theano represents a set of constraints on potential
data objects. These constraints allow Theano to tailor C code to handle
them and to statically optimize the computation graph. For instance,
the :ref:`irow <
predefinedtypes
>` type in the ``theano.tensor`` package
the :ref:`irow <
libdoc_tensor_creation
>` type in the ``theano.tensor`` package
gives the following constraints on the data the Variables of type ``irow``
may contain:
...
...
@@ -273,8 +272,8 @@ that declares the right data types and that contains the right number
of loops over the dimensions.
Note that a Theano :ref:`type` is not equivalent to a Python type or
class. Indeed, in Theano, :ref:`irow <
predefinedtypes
>` and :ref:`dmatrix
<
predefinedtypes
>` both use ``numpy.ndarray`` as the underlying type
class. Indeed, in Theano, :ref:`irow <
libdoc_tensor_creation
>` and :ref:`dmatrix
<
libdoc_tensor_creation
>` both use ``numpy.ndarray`` as the underlying type
for doing computations and storing data, yet they are different Theano
Types. Indeed, the constraints set by ``dmatrix`` are:
...
...
@@ -311,8 +310,7 @@ Variables. For example, when I type
>>> x = theano.tensor.ivector()
>>> y = -x
``x`` and ``y`` are both Variables, i.e. instances of the :api:`Variable
<theano.gof.graph.Variable>` class. The :ref:`type` of both ``x`` and
``x`` and ``y`` are both Variables, i.e. instances of the :class:`Variable` class. The :ref:`type` of both ``x`` and
``y`` is ``theano.tensor.ivector``.
Unlike ``x``, ``y`` is a Variable produced by a computation (in this
...
...
@@ -324,7 +322,7 @@ through ``y.owner``.
More specifically, a Variable is a basic structure in Theano that
represents a datum at a certain point in computation. It is typically
an instance of the class :
api:`Variable <theano.gof.graph.Variable>
` or
an instance of the class :
class:`Variable
` or
one of its subclasses.
A Variable ``r`` contains four important fields:
...
...
@@ -365,6 +363,7 @@ any circumstances modify the input. This means that a constant is
eligible to participate in numerous optimizations: constant inlining
in C code, constant folding, etc.
A constant does not need to be specified in a :ref:`function`'s list
A constant does not need to be specified in a :func:`function
<function.function>`'s list
of inputs. In fact, doing so will raise an exception.
doc/extending/op.txt
浏览文件 @
92cb4b40
...
...
@@ -12,7 +12,7 @@ computations. We'll start by defining multiplication.
Op's contract
=============
An Op (:
api:`gof.op
.Op`) is any object which defines the
An Op (:
class:`gof
.Op`) is any object which defines the
following methods:
...
...
@@ -134,9 +134,7 @@ following methods:
includes this Op.
For each method, the *default* is what :api:`theano.gof.op.Op` defines
for you. At a bare minimum, a new Op must define ``make_node`` and
``perform``, which have no defaults.
At a bare minimum, a new Op must define ``make_node`` and ``perform``, which have no defaults.
For more details, including the interface for providing a C
implementation of ``perform()``, refer to the documentation for :ref:`op`.
...
...
doc/extending/optimization.txt
浏览文件 @
92cb4b40
...
...
@@ -139,7 +139,7 @@ simplification described above:
Here's how it works: first, in ``add_requirements``, we add the
``ReplaceValidate`` :ref:`envfeature` located in
:
api:`theano.gof.
toolbox`. This feature adds the ``replace_validate``
:
ref:`libdoc_gof_
toolbox`. This feature adds the ``replace_validate``
method to ``env``, which is an enhanced version of ``replace`` that
does additional checks to ensure that we are not messing up the
computation graph (note: if ``ReplaceValidate`` was already added by
...
...
@@ -305,7 +305,7 @@ Theano defines some shortcuts to make LocalOptimizers:
.. function:: PatternSub(pattern1, pattern2)
Replaces all occurrences of the first pattern by the second pattern.
See :
api:`theano.gof.opt.
PatternSub`.
See :
class:`
PatternSub`.
.. code-block:: python
...
...
@@ -342,7 +342,7 @@ or ``PatternSub``, it is highly recommended to use them.
WRITEME: more about using PatternSub (syntax for the patterns, how to
use constraints, etc. - there's some decent doc at
:
api:`theano.gof.opt.
PatternSub` for those interested)
:
class:`
PatternSub` for those interested)
...
...
@@ -376,8 +376,8 @@ Definition of optdb
-------------------
optdb is an object which is an instance of
:
api:`theano.gof.SequenceDB <theano.gof.
optdb.SequenceDB>`,
itself a subclass of :
api:`theano.gof.DB <theano.gof.
optdb.DB>`.
:
class:`SequenceDB <
optdb.SequenceDB>`,
itself a subclass of :
class:`DB <
optdb.DB>`.
There exist (for now) two types of DB, SequenceDB and EquilibriumDB.
When given an appropriate Query, DB objects build an Optimizer matching
the query.
...
...
@@ -399,7 +399,7 @@ well and the LocalOptimizers they return will be put in their places
(note that as of yet no DB can produce LocalOptimizer objects, so this
is a moot point).
Theano contains one principal DB object, :
api:`theano
.gof.optdb`, which
Theano contains one principal DB object, :
ref:`libdoc
.gof.optdb`, which
contains all of Theano's optimizers with proper tags. It is
recommended to insert new Optimizers in it. As mentioned previously,
optdb is a SequenceDB, so, at the top level, Theano applies a sequence
...
...
@@ -411,33 +411,35 @@ Query
A Query is built by the following call:
::
.. code-block:: python
theano.gof.Query(include, require = None, exclude = None, subquery = None)
.. attribute:: include
.. class:: Query
.. attribute:: include
A set of tags (a tag being a string) such that every
optimization obtained through this Query must have **one** of the tags
listed. This field is required and basically acts as a starting point
for the search.
A set of tags (a tag being a string) such that every
optimization obtained through this Query must have **one** of the tags
listed. This field is required and basically acts as a starting point
for the search.
.. attribute:: require
.. attribute:: require
A set of tags such that every optimization obtained
through this Query must have **all** of these tags.
A set of tags such that every optimization obtained
through this Query must have **all** of these tags.
.. attribute:: exclude
.. attribute:: exclude
A set of tags such that every optimization obtained
through this Query must have **none** of these tags.
A set of tags such that every optimization obtained
through this Query must have **none** of these tags.
.. attribute:: subquery
.. attribute:: subquery
optdb can contain sub-databases; subquery is a
dictionary mapping the name of a sub-database to a special Query.
If no subquery is given for a sub-database, the original Query will be
used again.
optdb can contain sub-databases; subquery is a
dictionary mapping the name of a sub-database to a special Query.
If no subquery is given for a sub-database, the original Query will be
used again.
Furthermore, a Query object includes three methods, ``including``,
``requiring`` and ``excluding`` which each produce a new Query object
...
...
doc/extending/type.txt
浏览文件 @
92cb4b40
...
...
@@ -22,69 +22,71 @@ i.e. the same default argument names and values. If you wish to add
extra arguments to any of these methods, these extra arguments must have
default values.
..
function:: filter(value, strict=False)
..
class:: PureType
This casts a value to match the Type and returns the
casted value. If ``value`` is incompatible with the Type,
the method must raise an exception. If ``strict`` is True, ``filter`` must return a
reference to ``value`` (i.e. casting prohibited)
.. method:: filter(value, strict=False)
We need to define ``filter`` with two arguments. The second argument
must be called ``strict`` (Theano often calls it by keyword) and must
have a default value of ``False``.
This casts a value to match the Type and returns the
casted value. If ``value`` is incompatible with the Type,
the method must raise an exception. If ``strict`` is True, ``filter`` must return a
reference to ``value`` (i.e. casting prohibited)
.. function:: is_valid_value(value)
We need to define ``filter`` with two arguments. The second argument
must be called ``strict`` (Theano often calls it by keyword) and must
have a default value of ``False``.
Returns True iff the value is compatible with the Type. If
``filter(value, strict = True)`` does not raise an exception, the
value is compatible with the Type.
.. method:: is_valid_value(value)
*Default:* True iff ``filter(value, strict = True)`` does not raise
an exception.
Returns True iff the value is compatible with the Type. If
``filter(value, strict = True)`` does not raise an exception, the
value is compatible with the Type.
.. function:: values_eq(a, b)
*Default:* True iff ``filter(value, strict = True)`` does not raise
an exception.
Returns True iff ``a`` and ``b`` are equal.
.. method:: values_eq(a, b)
*Default:* ``a == b``
Returns True iff ``a`` and ``b`` are equal.
.. function:: values_eq_approx(a, b)
*Default:* ``a == b``
Returns True iff ``a`` and ``b`` are approximately equal, for a
definition of "approximately" which varies from Type to Type.
.. method:: values_eq_approx(a, b)
*Default:* ``values_eq(a, b)``
Returns True iff ``a`` and ``b`` are approximately equal, for a
definition of "approximately" which varies from Type to Type.
.. function:: make_variable(name=None)
*Default:* ``values_eq(a, b)``
Makes a :term:`Variable` of this Type with the specified name, if
``name`` is not ``None``. If ``name`` is ``None``, then the Variable does
not have a name. The Variable will have its ``type`` field set to
the Type object.
.. method:: make_variable(name=None)
*Default:* there is a generic definition of this in Type. The
Variable's ``type`` will be the object that defines this method (in
other words, ``self``).
Makes a :term:`Variable` of this Type with the specified name, if
``name`` is not ``None``. If ``name`` is ``None``, then the Variable does
not have a name. The Variable will have its ``type`` field set to
the Type object.
.. function:: __call__(name=None)
*Default:* there is a generic definition of this in Type. The
Variable's ``type`` will be the object that defines this method (in
other words, ``self``).
Syntactic shortcut to ``make_variable``.
.. method:: __call__(name=None)
*Default:* ``make_variable``
Syntactic shortcut to ``make_variable``.
.. function:: __eq__(other)
*Default:* ``make_variable``
Used to compare Type instances themselves
.. method:: __eq__(other)
*Default:* ``object.__eq__``
Used to compare Type instances themselves
.. function:: __hash__()
*Default:* ``object.__eq__``
Types should not be mutable, so it should be OK to define a hash
function. Typically this function should hash all of the terms
involved in ``__eq__``.
.. method:: __hash__()
*Default:* ``id(self)``
Types should not be mutable, so it should be OK to define a hash
function. Typically this function should hash all of the terms
involved in ``__eq__``.
*Default:* ``id(self)``
For each method, the *default* is what ``Type`` defines
for you. So, if you create an instance of ``Type`` or an
...
...
doc/glossary.txt
浏览文件 @
92cb4b40
...
...
@@ -13,37 +13,12 @@ Glossary of terminology
Broadcasting
Broadcasting is a mechanism which allows tensors with
different numbers of dimensions to be added or multiplied
together by (virtually) replicating the smaller tensor along
the dimensions that it is lacking.
In a nutshell, broadcasting is the mechanism by which a scalar
may be added to a matrix, a vector to a matrix or a scalar to
a vector.
.. figure:: bcast.png
Broadcasting a row matrix. T and F respectively stand for
True and False and indicate along which dimensions we allow
broadcasting.
If the second argument were a vector, its shape would be
``(2,)`` and its broadcastable pattern ``(F,)``. They would
be automatically expanded to the **left** to match the
dimensions of the matrix (adding ``1`` to the shape and ``T``
to the pattern), resulting in ``(1, 2)`` and ``(T, F)``.
It would then behave just like the example above.
Unlike numpy which does broadcasting dynamically, Theano needs
to know, for any operation which supports broadcasting, which
dimensions will need to be broadcasted. When applicable, this
information is given in the :term:`Type` of a :term:`Variable`.
See also:
* :ref:`How broadcasting is used in Theano's tensor types <tensortypes>`
different numbers of dimensions to be used in element-by-element
(elementwise) computations. It works by
(virtually) replicating the smaller tensor along
the dimensions that it is lacking.
For more detail, see :ref:`libdoc_tensor_broadcastable`, and also
* `SciPy documentation about numpy's broadcasting <http://www.scipy.org/EricsBroadcastingDoc>`_
* `OnLamp article about numpy's broadcasting <http://www.onlamp.com/pub/a/python/2000/09/27/numerically.html>`_
...
...
@@ -79,6 +54,9 @@ Glossary of terminology
others. These operations are all instances of :api:`Elemwise
<theano.tensor.elemwise.Elemwise>`.
Expression
See :term:`Apply`
Expression Graph
A directed, acyclic set of connected :term:`Variable` and
:term:`Apply` nodes that express symbolic functional relationship
...
...
@@ -89,7 +67,6 @@ Glossary of terminology
:term:`Type`, or read more about :ref:`tutorial_graphstructures`.
Destructive
An :term:`Op` is destructive (of particular input[s]) if its
computation requires that one or more inputs be overwritten or
otherwise invalidated. For example, :term:`inplace` Ops are
...
...
@@ -110,13 +87,24 @@ Glossary of terminology
Inplace computations are computations that destroy their inputs as a
side-effect. For example, if you iterate over a matrix and double
every element, this is an inplace operation because when you are done,
the original input has been overwritten.
the original input has been overwritten. Ops representing inplace
computations are :term:`destructive`, and by default these can only be
inserted by optimizations, not user code.
Linker
Part of a function :term:`Mode` -- an object responsible for 'running'
the compiled function. Among other things, the linker determines whether computations are carried out with C or Python code.
Merge
A simple optimization in which redundant :term:`Apply` nodes are
combined. For example, in ``function([x,y], [(x+y)*2, (x+y)*3])`` the merge
optimization will ensure that ``x`` and ``y`` are only added once.
Mode
An object providing an :term:`optimizer` and a :term:`linker` that is
passed to :term:`theano.funcion`. It parametrizes how an expression
graph is converted to a callable object.
Op
The ``.op`` of an :term:`Apply`, together with its symbolic inputs
fully determines what kind of computation will be carried out for that
...
...
@@ -128,13 +116,18 @@ Glossary of terminology
See also :term:`Variable`, :term:`Type`, and :term:`Apply`,
or read more about :ref:`tutorial_graphstructures`.
Expression
See :term:`Apply`
Optimizer
An instance of :class:`Optimizer`, which has the capacity to provide
:term:`optimization`s.
Optimization
A :term:`graph` transformation applied by an :term:`optimizer` during
the compilation of a :term:`graph` by :term:`theano.function`.
Storage
The memory that is used to store the value of a Variable. In most
cases storage is internal to a compiled function, but in some cases
(such as :term:`constant` and :term:`<shared variable>` the storage is not internal.
(such as :term:`constant` and :term:`
shared variable
<shared variable>` the storage is not internal.
Shared Variable
A :term:`Variable` whose value may be shared between multiple functions. See :func:`shared` and :func:`theano.function <function.function>`.
...
...
doc/library/tensor/basic.txt
浏览文件 @
92cb4b40
...
...
@@ -168,32 +168,27 @@ bytes, we would do:
Shared Variable
---------------
Yet another way of creating a special type of Theano variable is by using
:func:`shared` as in the example below:
Another way of creating a TensorVariable (a TensorSharedVariable to be
precise) is by calling :func:`shared()`
.. code-block:: python
x = shared(
value, name
)
x = shared(
numpy.random.randn(3,4)
)
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`.
This will return a :term:`shared variable <shared variable>` whose ``.value`` is
a numpy ndarray. The number of dimensions and dtype of the Variable are
inferred from the ndarray argument.
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.
For additional information, see the :func:`shared` documentation.
Autocasting
-----------
Theano does autocasting of numpy ndarray or python floats/ints into
Theano constants.
Theano does autocasting of python floats/ints into Theano constants.
TODO: What does (or compatible) mean? Talk about casting rules, refer .
TODO: link to floatX (?)
..
TODO: What does (or compatible) mean? Talk about casting rules, refer .
..
TODO: link to floatX (?)
.. function:: as_tensor_variable(x, ...)
...
...
@@ -438,8 +433,6 @@ information is given in the :ref:`type` of a *Variable*.
See also:
* :ref:`How broadcasting is used in Theano's tensor types <tensortypes>`
* `SciPy documentation about numpy's broadcasting <http://www.scipy.org/EricsBroadcastingDoc>`_
* `OnLamp article about numpy's broadcasting <http://www.onlamp.com/pub/a/python/2000/09/27/numerically.html>`_
...
...
doc/tutorial/debug_faq.txt
浏览文件 @
92cb4b40
...
...
@@ -130,19 +130,14 @@ This is actually so simple the debugging could be done easily, but it's for
illustrative purposes. As the matrices can't be element-wise multiplied
(unsuitable shapes), we get the following exception:
::
.. code-block:: text
File "ex.py", line 14, in <module>
f(mat1, mat2)
File "/u/username/Theano/theano/compile/function_module.py", line 451, in
__call__
File "/u/username/Theano/theano/gof/link.py", line 271, in
streamline_default_f
File "/u/username/Theano/theano/gof/link.py", line 267, in
streamline_default_f
File "/u/username/Theano/theano/gof/cc.py", line 1049, in execute
ValueError: ('Input dimension mis-match. (input[0].shape[0] = 3,
input[1].shape[0] = 5)',
Elemwise{mul,no_inplace}(a, b), Elemwise{mul,no_inplace}(a, b))
File "/u/username/Theano/theano/compile/function_module.py", line 451, in __call__
File "/u/username/Theano/theano/gof/link.py", line 271, in streamline_default_f
File "/u/username/Theano/theano/gof/link.py", line 267, in streamline_default_f
File "/u/username/Theano/theano/gof/cc.py", line 1049, in execute ValueError: ('Input dimension mis-match. (input[0].shape[0] = 3, input[1].shape[0] = 5)', Elemwise{mul,no_inplace}(a, b), Elemwise{mul,no_inplace}(a, b))
The call stack contains a few useful informations to trace back the source
of the error. There's the script where the compiled function was called --
...
...
@@ -160,21 +155,20 @@ dimensions of the matrices involved, but for the sake of example say we'd
need the other dimensions to pinpoint the error. First, we re-launch with
the debugger module and run the program with "c":
::
python -m pdb ex.py
> /u/username/experiments/doctmp1/ex.py(1)<module>()
-> import theano
(Pdb) c
.. code-block:: text
python -m pdb ex.py
> /u/username/experiments/doctmp1/ex.py(1)<module>()
-> import theano
(Pdb) c
Then we get back the above error printout, but the interpreter breaks in
that state. Useful commands here are
* "up" and "down" (to move up and down the call stack),</li>
* "l" (to print code around the line in the current stack position),</li>
* "p variable_name" (to print the string representation of
'variable_name'),</li>
* "p dir(object_name)", using the Python dir() function to print the list of
an object's members
* "up" and "down" (to move up and down the call stack),
* "l" (to print code around the line in the current stack position),
* "p variable_name" (to print the string representation of 'variable_name'),
* "p dir(object_name)", using the Python dir() function to print the list of an object's members
Here, for example, I do "up", and a simple "l" shows me there's a local
variable "node". This is the "node" from the computation graph, so by
...
...
doc/tutorial/symbolic_graphs.txt
浏览文件 @
92cb4b40
.. _
symbolic_graph
:
.. _
tutorial_graphstructures
:
================
Graph Structures
...
...
@@ -77,7 +77,7 @@ Optimizations
=============
When compiling a Theano function, what you give to the
:
ref:`theano.function <libdoc_compile_
function>` is actually a graph
:
func:`theano.function <function.
function>` is actually a graph
(starting from the outputs variables you can traverse the graph up to
the input variables). While this graph structure shows how to compute
the output from the input, it also offers the posibility to improve the
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论