Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c3491847
提交
c3491847
authored
1月 14, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
merged doc/advanced -> doc/sandbox
上级
aa308ecc
全部展开
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
0 行增加
和
146 行删除
+0
-146
module.txt
doc/advanced/module.txt
+0
-146
ccodegen.txt
doc/sandbox/ccodegen.txt
+0
-0
compilation.txt
doc/sandbox/compilation.txt
+0
-0
debugging_with_stepmode.txt
doc/sandbox/debugging_with_stepmode.txt
+0
-0
env.txt
doc/sandbox/env.txt
+0
-0
features.txt
doc/sandbox/features.txt
+0
-0
function.txt
doc/sandbox/function.txt
+0
-0
index2.txt
doc/sandbox/index2.txt
+0
-0
module.txt
doc/sandbox/module.txt
+0
-0
module2.txt
doc/sandbox/module2.txt
+0
-0
没有找到文件。
doc/advanced/module.txt
deleted
100644 → 0
浏览文件 @
aa308ecc
.. _moduleinterface:
================
Module Interface
================
A Theano Module is like Theano's version of a file.
When you instantiate a ``Module()``, you are creating a blank file.
Into this file you can put both symbolic and non-symbolic objects.
Non-symbolic objects are like constants (technically literals) in the file.
Symbolic objects are like variables and functions.
The functions in a Module are called Methods.
The variables in a Module (and submodules) are global.
Module Methods have access to all these global variables.
To use a Module, you need to compile it.
This is done by calling `Module.make()`.
The result of compiling a Module is a ModuleInstance, this is the compiled
version of your Theano file.
In the ModuleInstance, your symbolic variables have become containers (containing None),
and your Methods have become callable functions.
You should initialize the symbolic variables by calling
``ModuleInstance.initialize()`` (although make() will call it for you,
on the top-level ModuleInstance.)
You can compile a Module several times, to create multiple ModuleInstances.
Each of these will have its own copy of all program literals.
Module Graph
------------
Components can be grouped into a directed graph.
When we call `make`, this graph is replicated with ComponentInstances instead of
Components. Wheras Components are represent symbolic things (ie. Variables), ComponentInstances represent non-symbolic ones (ie. sparse matrices, ndarrays, callable functions).
.. index::
single: Component
single: component; Component
.. _component:
---------
Component
---------
All of the elements of what is called the "module system" or "modules" are
components.
A component subclass is represents a symbolic theano thing, and implements the
``build`` function.
The ``build`` function is responsible for converting the symbolic thing into a
non-symbolic thing.
Compiling with make
-------------------
Conversion from a Component graph to a ComponentInstance graph is performed by `Component.make`.
This method traverses the Component graph in multiple passes.
In the first pass (the allocate pass), it creates storage for all Variables that are contained in the graph (see
`Component.allocate`). These are the module variables.
In the second pass (the build pass), it creates functions that (in general) operate on these module variables.
This pass also serves to construct all ComponentInstance-derived instances as well, such as
`ModuleInstance`s. The objects that are returned from this second pass are the return value of
`Component.make`.
In the third pass (the initialize pass), is optional and not necessarily recursive through the
graph.
The purpose of the third pass is to call the initialize method of the ComponentInstances built
during the second pass.
During this pass the ComponentInstance graph is complete. It is a good time to fill storage
allocated in phase 1 with sensible values.
.. index::
single: External
single: component; External
.. _external:
--------
External
--------
WRITEME
.. index::
single: Member
single: component; Member
.. _member:
------
Member
------
WRITEME
.. index::
single: Method
single: component; Method
.. _method:
------
Method
------
WRITEME
.. index::
single: Module
single: component; Module
.. _module:
------
Module
------
A Module instance can contain objects as attributes.
This makes it something like a class in the way that Method is
analogous to a function.
A Module is meant to contain Components.
Attributes which are not Components themselves must at least be transform-able
into Components by :api:`compile.module.wrap`. If a Module contains something
that is not convertible into a Component, then it is not possible to compile
that Module with ``make``.
Old Text
--------
In the Module system, the analog of the file is the `Module`, the analog of the function is the
`Method`, and the analog of the variable is the `Member`. Module, Member, and Method all work
at the symbolic level. Once a graph of Modules, Members, and Methods is ready for use, it must
be compiled with a call to `make` which will return an isomorphic structure in which Modules
have become `ModuleInstances`, Members have become `Container`s, and Methods have become
`Function`s.
This structure contains numbers and functions, and is ready for computation.
doc/
advanced
/ccodegen.txt
→
doc/
sandbox
/ccodegen.txt
浏览文件 @
c3491847
File moved
doc/
advanced
/compilation.txt
→
doc/
sandbox
/compilation.txt
浏览文件 @
c3491847
File moved
doc/
advanced
/debugging_with_stepmode.txt
→
doc/
sandbox
/debugging_with_stepmode.txt
浏览文件 @
c3491847
File moved
doc/
advanced
/env.txt
→
doc/
sandbox
/env.txt
浏览文件 @
c3491847
File moved
doc/
advanced
/features.txt
→
doc/
sandbox
/features.txt
浏览文件 @
c3491847
File moved
doc/
advanced
/function.txt
→
doc/
sandbox
/function.txt
浏览文件 @
c3491847
File moved
doc/
advanced/index
.txt
→
doc/
sandbox/index2
.txt
浏览文件 @
c3491847
File moved
doc/sandbox/module.txt
浏览文件 @
c3491847
差异被折叠。
点击展开。
doc/sandbox/module2.txt
0 → 100644
浏览文件 @
c3491847
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论