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 个修改的文件
包含
41 行增加
和
36 行删除
+41
-36
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
+31
-26
没有找到文件。
doc/basic_tutorial/adding.txt
浏览文件 @
0c6696f8
...
...
@@ -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``.
>>> print pp(z)
x + y
(x + y)
-------------------------------------------
...
...
doc/basic_tutorial/examples.txt
浏览文件 @
0c6696f8
...
...
@@ -97,17 +97,17 @@ Here is code to compute this gradient:
>>> y = x**2
>>> gy = T.grad(y, x)
>>> 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(4)
array(8.0)
>>> f(94.2)
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.
``fill(
x ** 2, 1.0)`` means to make a matrix of the same shape as ``x **
2`` and fill it with 1.0.
``fill(
(x ** 2), 1.0)`` means to make a matrix of the same shape as
``x **
2`` and fill it with 1.0.
.. note::
The optimizer will simplify the symbolic gradient expression.
...
...
@@ -252,7 +252,7 @@ array(5.9000000000000004)
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.
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,
but can identify many kinds of problems.
The default mode is typically
'FAST_RUN'
, but it can be controlled via
the environment variable
'THEANO_DEFAULT_MODE'
, which can in turn be
overridden by setting
``theano.compile.mode.default_mode`
` directly,
The default mode is typically
``FAST_RUN``
, but it can be controlled via
the environment variable
``THEANO_DEFAULT_MODE``
, which can in turn be
overridden by setting
:api:`theano.compile.mode.default_mode
` directly,
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
whether C or python implementations are used, read
...
...
doc/basic_tutorial/module.txt
浏览文件 @
0c6696f8
...
...
@@ -49,19 +49,19 @@ Here we instantiate an empty Module.
>>> m.state = T.dscalar()
>>> m.inc = T.dscalar('inc')
Then we declares for use with our Module.
Since we assign these input Variables as attributes of the Module,
they will be *member Variables* of the Module.
Then we declare
Variable
s for use with our Module.
Since we assign these input Variables as attributes of the Module,
they will be *member Variables* of the Module.
Member Variables are special in a few ways, which we will see shortly.
.. note::
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::
Since we made it a member of ``m``, the ``acc`` object will have an
attribute called ``inc``. This attribute will keep its default value of
None throughout the example.
...
...
@@ -70,9 +70,9 @@ Member Variables are special in a few ways, which we will see shortly.
>>> m.new_state = m.state + m.inc
This line creates a Variable corresponding to some symbolic computation.
Although this line also assigns a Variable to a Module attribute, it
does not
become a member Variable like state and inc because it represents an expression
re
sult
.
Although this line also assigns a Variable to a Module attribute, it
does not become a member Variable like ``state`` and ``inc`` because it
re
presents an expression *result*
.
>>> m.add = Method(m.inc, m.new_state, {m.state: m.new_state})
...
...
@@ -88,26 +88,28 @@ Here we declare a Method. The three arguments are as follow:
>>> acc = m.make(state = 0)
This line is what does the magic (well, compilation).
The ``m`` object contains symbolic things such as Variables and Methods.
The ``m`` object contains symbolic things such as Variables and Methods.
Calling ``make`` on ``m`` creates an object that can do real
computation and whose attributes contain values such as numbers and numpy
ndarrays.
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
Variables. By using the string 'state' as a keyword argument, we tell Theano to
store the number 0 for the member Variable called 'state'. By not mentioning
the 'inc' variable, we associate None to the 'inc' Variable.
In the ``acc`` object, make allocates room to store numbers for ``m``'s
member Variables. By using the string ``'state'`` as a keyword
argument, we tell Theano to store the number ``0`` for the member
Variable called ``state``. By not mentioning the ``inc`` variable, we
associate ``None`` to the ``inc`` Variable.
>>> acc.state, acc.inc
array(0.0), None
Since 'state' was declared as a member Variable of 'm', we can access it's value
in the 'acc' object by the same attribute. Ditto for 'inc'.
Since ``state`` was declared as a member Variable of ``m``, we can
access it's value in the ``acc`` object by the same attribute.
Ditto for ``inc``.
.. note::
Members can also be accessed using a dictionary-like notation. The syntax
``acc.value[m.state]`` is equivalent to ``acc[m.state]``, and in this case,
``acc.state``. The dictionary-like syntax works for member Variables that
...
...
@@ -119,16 +121,19 @@ array(2.0)
>>> acc.state, acc.inc
array(2.0), None
When we call the ``acc.add`` method, the value 2 is used for the symbolic 'm.inc'
The first line evaluates the output and all the updates given to the
'acc' Method's ``updates`` field. We only had
one update which mapped ``state`` to ``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
'm.inc'. If we had left 'm.inc' out of the Method input list, then it the
method would have used the module's storage for ``m.inc`` instead.
When we call the ``acc.add`` method, the value ``2`` is used for the
symbolic ``m.inc``. The first line evaluates the output and all the
updates given in the ``updates`` argument of the call to Method that
declared ``acc``. We only had one update which mapped ``state`` to
``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 in the call to Method that created
``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
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论