Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
73ac6dba
提交
73ac6dba
authored
11月 11, 2010
作者:
James Bergstra
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
corrections to aliasing.txt
上级
0f7e6fad
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
13 行增加
和
7 行删除
+13
-7
aliasing.txt
doc/tutorial/aliasing.txt
+13
-7
没有找到文件。
doc/tutorial/aliasing.txt
浏览文件 @
73ac6dba
...
@@ -73,18 +73,19 @@ subsequently make to ``np_array`` have no effect on our shared variable.
...
@@ -73,18 +73,19 @@ subsequently make to ``np_array`` have no effect on our shared variable.
np_array += 1 # now it is an array of 2.0 s
np_array += 1 # now it is an array of 2.0 s
s_default.value # -> array([1.0, 1.0])
s_default.value # -> array([1.0, 1.0])
s_false.value # -> array([2.0, 2.0])
s_false.value # -> array([1.0, 1.0])
s_true.value # -> array([2.0, 2.0])
If we are running this with the CPU as the device,
If we are running this with the CPU as the device,
then changes we make to np_array *right away* will show up in ``s_
fals
e.value``
then changes we make to np_array *right away* will show up in ``s_
tru
e.value``
because numpy arrays are mutable, and ``s_
fals
e`` is using the ``np_array``
because numpy arrays are mutable, and ``s_
tru
e`` is using the ``np_array``
object as it's internal buffer.
object as it's internal buffer.
However, this aliasing of ``np_array`` and ``s_
fals
e`` is *inconsistent and fragile*!
However, this aliasing of ``np_array`` and ``s_
tru
e`` is *inconsistent and fragile*!
It is inconsistent because if Theano is using a GPU device, then the borrow flag
It is inconsistent because if Theano is using a GPU device, then the borrow flag
has no effect.
has no effect.
It is fragile because
It is fragile because
if we call a theano function that updates the value of ``s_
fals
e`` the aliasing
if we call a theano function that updates the value of ``s_
tru
e`` the aliasing
relationship *may* or *may not* be broken (it depends on what the Theano
relationship *may* or *may not* be broken (it depends on what the Theano
function does).
function does).
...
@@ -135,7 +136,7 @@ factors (e.g. the compute device, the dtype of the numpy array).
...
@@ -135,7 +136,7 @@ factors (e.g. the compute device, the dtype of the numpy array).
.. code-block:: python
.. code-block:: python
v_internal = s.get_
internal_
value(borrow=True, return_internal_type=True)
v_internal = s.get_value(borrow=True, return_internal_type=True)
It is possible to use ``borrow=False`` in conjunction with
It is possible to use ``borrow=False`` in conjunction with
``return_internal_type=True``, which will return a deep copy of the internal object.
``return_internal_type=True``, which will return a deep copy of the internal object.
...
@@ -188,12 +189,17 @@ that control how ``theano.function`` handles its arguments and return value[s].
...
@@ -188,12 +189,17 @@ that control how ``theano.function`` handles its arguments and return value[s].
Borrowing an input means that Theano will treat the argument you provide as if
Borrowing an input means that Theano will treat the argument you provide as if
it were part of Theano's pool of temporaries. Consequently, your input
it were part of Theano's pool of temporaries. Consequently, your input
may be reused as a buffer (and overwritten!) during the computation of other variables in the
may be reused as a buffer (and overwritten!) during the computation of other variables in the
course of evaluating that function (e.g. ``f``).
course of evaluating that function (e.g. ``f``).
Borrowing an output means that Theano will not insist on allocating a fresh
Borrowing an output means that Theano will not insist on allocating a fresh
output buffer every time you call the function. It will possibly reuse the same one as
output buffer every time you call the function. It will possibly reuse the same one as
a previous call, and overwrite the old contents. Consequently, it may overwrite
a previous call, and overwrite the old contents. Consequently, it may overwrite
old return values by side effect.
old return values by side effect.
Those return values may also be overwritten in
the course of evaluating *another compiled function* (for example, the output
may be aliased to a shared variable). So be careful to use a borrowed return
value right away before calling any more Theano functions.
It is also possible to pass an ``return_internal_type=True`` flag to the ``Out``
It is also possible to pass an ``return_internal_type=True`` flag to the ``Out``
variable which has the same interpretation as the ``return_internal_type`` flag
variable which has the same interpretation as the ``return_internal_type`` flag
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论