Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e597582a
提交
e597582a
authored
11月 12, 2010
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
small update to the aliasing.txt file.
上级
66b75988
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
9 行增加
和
5 行删除
+9
-5
aliasing.txt
doc/tutorial/aliasing.txt
+9
-5
没有找到文件。
doc/tutorial/aliasing.txt
浏览文件 @
e597582a
...
@@ -60,9 +60,9 @@ A ``borrow`` argument can be provided to the shared-variable constructor.
...
@@ -60,9 +60,9 @@ A ``borrow`` argument can be provided to the shared-variable constructor.
import numpy, theano
import numpy, theano
np_array = numpy.ones(2, dtype='float32')
np_array = numpy.ones(2, dtype='float32')
s_default = shared(np_array)
s_default =
theano.
shared(np_array)
s_false = shared(np_array, borrow=False)
s_false =
theano.
shared(np_array, borrow=False)
s_true = shared(np_array, borrow=True)
s_true =
theano.
shared(np_array, borrow=True)
By default (``s_default``) and when explicitly setting ``borrow=False``, the
By default (``s_default``) and when explicitly setting ``borrow=False``, the
shared variable we construct gets a [deep] copy of ``np_array``. So changes we
shared variable we construct gets a [deep] copy of ``np_array``. So changes we
...
@@ -110,7 +110,7 @@ A ``borrow`` argument can also be used to control how a shared variable's value
...
@@ -110,7 +110,7 @@ A ``borrow`` argument can also be used to control how a shared variable's value
.. code-block:: python
.. code-block:: python
s = shared(np_array)
s =
theano.
shared(np_array)
v_false = s.get_value(borrow=False) # N.B. borrow default is False
v_false = s.get_value(borrow=False) # N.B. borrow default is False
v_true = s.get_value(borrow=True)
v_true = s.get_value(borrow=True)
...
@@ -124,7 +124,7 @@ But both of these calls might create copies of the internal memory.
...
@@ -124,7 +124,7 @@ But both of these calls might create copies of the internal memory.
The reason that ``borrow=True`` might still make a copy is that the internal
The reason that ``borrow=True`` might still make a copy is that the internal
representation of a shared variable might not be what you expect. When you
representation of a shared variable might not be what you expect. When you
create a variable by passing a numpy array for example, then ``get_value()``
create a
shared
variable by passing a numpy array for example, then ``get_value()``
must return a numpy array too. That's how Theano can make the GPU use
must return a numpy array too. That's how Theano can make the GPU use
transparent. But when you are using a GPU (or in future perhaps a remote machine), then the numpy.ndarray
transparent. But when you are using a GPU (or in future perhaps a remote machine), then the numpy.ndarray
is not the internal representation of your data.
is not the internal representation of your data.
...
@@ -200,6 +200,7 @@ Those return values may also be overwritten in
...
@@ -200,6 +200,7 @@ Those return values may also be overwritten in
the course of evaluating *another compiled function* (for example, the output
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
may be aliased to a shared variable). So be careful to use a borrowed return
value right away before calling any more Theano functions.
value right away before calling any more Theano functions.
The default is of course to *not borrow* internal results.
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
...
@@ -214,4 +215,7 @@ When a return value ``y`` is large (in terms of memory footprint), and you only
...
@@ -214,4 +215,7 @@ When a return value ``y`` is large (in terms of memory footprint), and you only
away when it's returned, then consider marking it with an ``Out(y,
away when it's returned, then consider marking it with an ``Out(y,
borrow=True)``.
borrow=True)``.
Shared variable .value attribute
================================
TODO: talk about sharedvar.value and the associated config variable.
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论