Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c4f1ea08
提交
c4f1ea08
authored
3月 31, 2009
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update doc to match real outputs.
上级
7344f170
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
12 行增加
和
10 行删除
+12
-10
module.txt
doc/basic_tutorial/module.txt
+12
-10
没有找到文件。
doc/basic_tutorial/module.txt
浏览文件 @
c4f1ea08
...
@@ -24,11 +24,11 @@ Let's use Module to re-implement :ref:`the example using state
...
@@ -24,11 +24,11 @@ Let's use Module to re-implement :ref:`the example using state
>>> m.sub = Method(m.inc, None, {m.state: m.state - m.inc})
>>> m.sub = Method(m.inc, None, {m.state: m.state - m.inc})
>>> acc = m.make(state = 0)
>>> acc = m.make(state = 0)
>>> acc.state, acc.inc
>>> acc.state, acc.inc
array(0.0), None
(array(0.0), None)
>>> acc.add(2)
>>> acc.add(2)
array(2.0)
array(2.0)
>>> acc.state, acc.inc
>>> acc.state, acc.inc
array(2.0), None
(array(2.0), None)
>>> acc.state = 39.99
>>> acc.state = 39.99
>>> acc.add(0.01)
>>> acc.add(0.01)
array(40.0)
array(40.0)
...
@@ -86,6 +86,10 @@ Here we declare a Method. The three arguments are as follow:
...
@@ -86,6 +86,10 @@ Here we declare a Method. The three arguments are as follow:
call the function that this Method compiles to, it will replace (update) the
call the function that this Method compiles to, it will replace (update) the
values associated with the member Variables.
values associated with the member Variables.
>>> m.sub = Method(m.inc, None, {m.state: m.state - m.inc})
We declare another Method, that has no outputs.
>>> acc = m.make(state = 0)
>>> acc = m.make(state = 0)
This line is what does the magic (well, compilation).
This line is what does the magic (well, compilation).
...
@@ -103,7 +107,7 @@ associate ``None`` to the ``inc`` Variable.
...
@@ -103,7 +107,7 @@ 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
Since ``state`` was declared as a member Variable of ``m``, we can
access it's value in the ``acc`` object by the same attribute.
access it's value in the ``acc`` object by the same attribute.
...
@@ -111,16 +115,14 @@ Ditto for ``inc``.
...
@@ -111,16 +115,14 @@ Ditto for ``inc``.
.. note::
.. note::
Members can also be accessed using a dictionary-like notation. The syntax
Members can also be accessed using a dictionary-like notation.
``acc.value[m.state]`` is equivalent to ``acc[m.state]``, and in this case,
The syntax ``acc['state']`` is equivalent to ``acc.state``.
``acc.state``. The dictionary-like syntax works for member Variables that
appear inside sub-modules, lists, dictionaries, and for whatever reason have
no name.
>>> acc.add(2)
>>> acc.add(2)
array(2.0)
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
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
symbolic ``m.inc``. The first line evaluates the output and all the
...
@@ -143,7 +145,7 @@ The state can also be set. When we manually set the value of a member
...
@@ -143,7 +145,7 @@ The state can also be set. When we manually set the value of a member
attribute like this, then subsequent calls to the methods of our module will
attribute like this, then subsequent calls to the methods of our module will
use the new value.
use the new value.
>>> acc.
call
(0.01)
>>> acc.
add
(0.01)
array(40.0)
array(40.0)
>>> acc.state
>>> acc.state
array(40.0)
array(40.0)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论