Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f16ac4a8
提交
f16ac4a8
authored
3月 27, 2009
作者:
james@X40
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
ef629114
16ef294f
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
20 行删除
+18
-20
module.txt
doc/basic_tutorial/module.txt
+18
-20
没有找到文件。
doc/basic_tutorial/module.txt
浏览文件 @
f16ac4a8
...
@@ -47,12 +47,12 @@ Here we instantiate an empty Module.
...
@@ -47,12 +47,12 @@ Here we instantiate an empty Module.
>>> m.state = T.dscalar()
>>> m.state = T.dscalar()
>>> m.inc = T.dscalar('inc')
Then we declare a Variable for use with our Module. That Variable will
Then we declares for use with our Module.
be a :ref:`member` of the Module, which means that it will be
Since we assign these input Variables as attributes of the Module,
accessible as a field of the object we will create later (for reading
they will be *member Variables* of the Module.
and writing). It will also be accessible from any :ref:`method`
Member Variables are special in a few ways, which we will see shortly.
defined in our Module.
.. note::
.. note::
...
@@ -60,11 +60,6 @@ defined in our Module.
...
@@ -60,11 +60,6 @@ defined in our Module.
be given the name 'state' automatically.
be given the name 'state' automatically.
>>> m.inc = T.dscalar('inc')
The ``inc`` variable doesn't need to be declared as a member of ``m`` because
we only use it as a Method input.
.. note::
.. note::
Since we made it a member of ``m``, the ``acc`` object will have an
Since we made it a member of ``m``, the ``acc`` object will have an
...
@@ -74,9 +69,10 @@ we only use it as a Method input.
...
@@ -74,9 +69,10 @@ we only use it as a Method input.
>>> m.new_state = m.state + m.inc
>>> m.new_state = m.state + m.inc
This line creates a Variable corresponding to some symbolic computation. It
This line creates a Variable corresponding to some symbolic computation.
doesn't matter to Theano whether we put it inside ``m`` or not. Feel free to
Although this line also assigns a Variable to a Module attribute, it does not
put such results of symbolic computation wherever is most convenient.
become a member Variable like state and inc because it represents 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})
...
@@ -97,16 +93,18 @@ Calling ``make`` on ``m`` creates an object that can do real
...
@@ -97,16 +93,18 @@ Calling ``make`` on ``m`` creates an object that can do real
computation and whose attributes contain values such as numbers and numpy
computation and whose attributes contain values such as numbers and numpy
ndarrays.
ndarrays.
The keyword arguments given to make are optional and are used to
At this point something special happens for our member Variables too.
assign initial values to each Member. If a Member is omitted, the
In the 'acc' object, make allocates room to store numbers for m's member
initial value is None.
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
>>> acc.state, acc.inc
array(0.0), None
array(0.0), None
Since
state was declared as a Member, we can access it using
Since
'state' was declared as a member Variable of 'm', we can access it's value
'.state
'.
in the 'acc' object by the same attribute. Ditto for 'inc
'.
.. note::
.. note::
...
@@ -118,8 +116,8 @@ Since state was declared as a Member, we can access it using
...
@@ -118,8 +116,8 @@ Since state was declared as a Member, we can access it using
>>> acc.add(2)
>>> acc.add(2)
array(2.0)
array(2.0)
>>> acc.state
>>> acc.state
, acc.inc
array(2.0)
array(2.0)
, None
When we call the ``acc.add`` method, all the updates given to the
When we call the ``acc.add`` method, all the updates given to the
corresponding Method's ``updates`` field are performed. We only had
corresponding Method's ``updates`` field are performed. We only had
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论