Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0c6696f8
提交
0c6696f8
authored
3月 31, 2009
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Small documentation corrections.
上级
9ca3b2ba
显示空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
36 行增加
和
31 行删除
+36
-31
adding.txt
doc/basic_tutorial/adding.txt
+1
-1
examples.txt
doc/basic_tutorial/examples.txt
+9
-9
module.txt
doc/basic_tutorial/module.txt
+26
-21
没有找到文件。
doc/basic_tutorial/adding.txt
浏览文件 @
0c6696f8
...
@@ -85,7 +85,7 @@ The second step is to combine ``x`` and ``y`` into their sum ``z``:
...
@@ -85,7 +85,7 @@ The second step is to combine ``x`` and ``y`` into their sum ``z``:
function to pretty-print out the computation associated to ``z``.
function to pretty-print out the computation associated to ``z``.
>>> print pp(z)
>>> print pp(z)
x + y
(x + y)
-------------------------------------------
-------------------------------------------
...
...
doc/basic_tutorial/examples.txt
浏览文件 @
0c6696f8
...
@@ -97,17 +97,17 @@ Here is code to compute this gradient:
...
@@ -97,17 +97,17 @@ Here is code to compute this gradient:
>>> y = x**2
>>> y = x**2
>>> gy = T.grad(y, x)
>>> gy = T.grad(y, x)
>>> pp(gy)
>>> pp(gy)
'
fill(x ** 2, 1.0) * 2 * x ** (2 - 1
)'
'
((fill((x ** 2), 1.0) * 2) * (x ** (2 - 1))
)'
>>> f = function([x], gy)
>>> f = function([x], gy)
>>> f(4)
>>> f(4)
array(8.0)
array(8.0)
>>> f(94.2)
>>> f(94.2)
array(188.40000000000001)
array(188.40000000000001)
In the example above, we can see from ``pp(g
w
)`` that we are computing
In the example above, we can see from ``pp(g
y
)`` that we are computing
the correct symbolic gradient.
the correct symbolic gradient.
``fill(
x ** 2, 1.0)`` means to make a matrix of the same shape as ``x **
``fill(
(x ** 2), 1.0)`` means to make a matrix of the same shape as
2`` and fill it with 1.0.
``x **
2`` and fill it with 1.0.
.. note::
.. note::
The optimizer will simplify the symbolic gradient expression.
The optimizer will simplify the symbolic gradient expression.
...
@@ -252,7 +252,7 @@ array(5.9000000000000004)
...
@@ -252,7 +252,7 @@ array(5.9000000000000004)
Mode
Mode
====
====
The ``mode`` parameter to
``theano.function`
` controls how the
The ``mode`` parameter to
:api:`theano.function
` controls how the
inputs-to-outputs graph is transformed into a callable object.
inputs-to-outputs graph is transformed into a callable object.
Theano defines the following modes by name:
Theano defines the following modes by name:
...
@@ -263,11 +263,11 @@ Theano defines the following modes by name:
...
@@ -263,11 +263,11 @@ Theano defines the following modes by name:
implementations. This mode can take much longer than the other modes,
implementations. This mode can take much longer than the other modes,
but can identify many kinds of problems.
but can identify many kinds of problems.
The default mode is typically
'FAST_RUN'
, but it can be controlled via
The default mode is typically
``FAST_RUN``
, but it can be controlled via
the environment variable
'THEANO_DEFAULT_MODE'
, which can in turn be
the environment variable
``THEANO_DEFAULT_MODE``
, which can in turn be
overridden by setting
``theano.compile.mode.default_mode`
` directly,
overridden by setting
:api:`theano.compile.mode.default_mode
` directly,
which can in turn be overridden by passing the keyword argument to
which can in turn be overridden by passing the keyword argument to
``theano.function`
`.
:api:`theano.function
`.
For a finer level of control over which optimizations are applied, and
For a finer level of control over which optimizations are applied, and
whether C or python implementations are used, read
whether C or python implementations are used, read
...
...
doc/basic_tutorial/module.txt
浏览文件 @
0c6696f8
...
@@ -49,7 +49,7 @@ Here we instantiate an empty Module.
...
@@ -49,7 +49,7 @@ Here we instantiate an empty Module.
>>> m.state = T.dscalar()
>>> m.state = T.dscalar()
>>> m.inc = T.dscalar('inc')
>>> m.inc = T.dscalar('inc')
Then we declares for use with our Module.
Then we declare
Variable
s for use with our Module.
Since we assign these input Variables as attributes of the Module,
Since we assign these input Variables as attributes of the Module,
they will be *member Variables* of the Module.
they will be *member Variables* of the Module.
Member Variables are special in a few ways, which we will see shortly.
Member Variables are special in a few ways, which we will see shortly.
...
@@ -57,7 +57,7 @@ Member Variables are special in a few ways, which we will see shortly.
...
@@ -57,7 +57,7 @@ Member Variables are special in a few ways, which we will see shortly.
.. note::
.. note::
There is no need to name the Variable explicitly here. ``m.state`` will
There is no need to name the Variable explicitly here. ``m.state`` will
be given the name
'state'
automatically.
be given the name
``'state'``
automatically.
.. note::
.. note::
...
@@ -70,9 +70,9 @@ Member Variables are special in a few ways, which we will see shortly.
...
@@ -70,9 +70,9 @@ Member Variables are special in a few ways, which we will see shortly.
>>> m.new_state = m.state + m.inc
>>> m.new_state = m.state + m.inc
This line creates a Variable corresponding to some symbolic computation.
This line creates a Variable corresponding to some symbolic computation.
Although this line also assigns a Variable to a Module attribute, it
does not
Although this line also assigns a Variable to a Module attribute, it
become a member Variable like state and inc because it represents an expression
does not become a member Variable like ``state`` and ``inc`` because it
re
sult
.
re
presents an expression *result*
.
>>> m.add = Method(m.inc, m.new_state, {m.state: m.new_state})
>>> m.add = Method(m.inc, m.new_state, {m.state: m.new_state})
...
@@ -94,17 +94,19 @@ computation and whose attributes contain values such as numbers and numpy
...
@@ -94,17 +94,19 @@ computation and whose attributes contain values such as numbers and numpy
ndarrays.
ndarrays.
At this point something special happens for our member Variables too.
At this point something special happens for our member Variables too.
In the 'acc' object, make allocates room to store numbers for m's member
In the ``acc`` object, make allocates room to store numbers for ``m``'s
Variables. By using the string 'state' as a keyword argument, we tell Theano to
member Variables. By using the string ``'state'`` as a keyword
store the number 0 for the member Variable called 'state'. By not mentioning
argument, we tell Theano to store the number ``0`` for the member
the 'inc' variable, we associate None to the 'inc' Variable.
Variable called ``state``. By not mentioning the ``inc`` variable, we
associate ``None`` to the ``inc`` Variable.
>>> acc.state, acc.inc
>>> acc.state, acc.inc
array(0.0), None
array(0.0), None
Since 'state' was declared as a member Variable of 'm', we can access it's value
Since ``state`` was declared as a member Variable of ``m``, we can
in the 'acc' object by the same attribute. Ditto for 'inc'.
access it's value in the ``acc`` object by the same attribute.
Ditto for ``inc``.
.. note::
.. note::
...
@@ -119,16 +121,19 @@ array(2.0)
...
@@ -119,16 +121,19 @@ array(2.0)
>>> acc.state, acc.inc
>>> acc.state, acc.inc
array(2.0), None
array(2.0), None
When we call the ``acc.add`` method, the value 2 is used for the symbolic 'm.inc'
When we call the ``acc.add`` method, the value ``2`` is used for the
The first line evaluates the output and all the updates given to the
symbolic ``m.inc``. The first line evaluates the output and all the
'acc' Method's ``updates`` field. We only had
updates given in the ``updates`` argument of the call to Method that
one update which mapped ``state`` to ``new_state`` and you can see
declared ``acc``. We only had one update which mapped ``state`` to
that it works as intended, adding the argument to the internal state.
``new_state`` and you can see that it works as intended, adding the
argument to the internal state.
Note also that 'acc.inc' is still None after our call. Since 'm.inc' was listed
as an input the Method, the method got it's own private storage container for
Note also that ``acc.inc`` is still ``None`` after our call. Since
'm.inc'. If we had left 'm.inc' out of the Method input list, then it the
``m.inc`` was listed as an input in the call to Method that created
method would have used the module's storage for ``m.inc`` instead.
``m.add``, when ``acc.add`` was created by the call to ``m.make``, a
private storage container was allocated to hold the first parameter.
If we had left ``m.inc`` out of the Method input list, then ``acc.add``
would have used ``acc.inc`` instead.
>>> acc.state = 39.99
>>> acc.state = 39.99
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论