Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ee650637
提交
ee650637
authored
3月 02, 2015
作者:
Sina Honari
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
adding documentation to addbroadcast() unbroadcast() and patternbroadcast()
上级
e9fee711
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
53 行增加
和
0 行删除
+53
-0
basic.py
theano/tensor/basic.py
+53
-0
没有找到文件。
theano/tensor/basic.py
浏览文件 @
ee650637
...
@@ -3265,9 +3265,26 @@ class Split(Op):
...
@@ -3265,9 +3265,26 @@ class Split(Op):
def
addbroadcast
(
x
,
*
axes
):
def
addbroadcast
(
x
,
*
axes
):
"""
"""
Make the input broadcastable in the specified axes.
Make the input broadcastable in the specified axes.
For example, addbroadcast(x, 0) will make the first dimension of
x broadcastable. When performing the function, if the length of
x along that dimension is not 1, a ValueError will be raised.
We apply the opt here not to pollute the graph especially during
We apply the opt here not to pollute the graph especially during
the gpu optimization
the gpu optimization
Parameters:
------------
x : tensor_like
Input theano tensor.
axis : an int or an iterable object such as list or tuple
of int values
The dimension along which the tensor x should be broadcastable.
if the length of x along these dimensions is not 1,
a ValueError will be raised.
returns:
----------
a theano tensor, which is broadcastable along the specified dimensions.
"""
"""
rval
=
Rebroadcast
(
*
[(
axis
,
True
)
for
axis
in
axes
])(
x
)
rval
=
Rebroadcast
(
*
[(
axis
,
True
)
for
axis
in
axes
])(
x
)
return
theano
.
tensor
.
opt
.
apply_rebroadcast_opt
(
rval
)
return
theano
.
tensor
.
opt
.
apply_rebroadcast_opt
(
rval
)
...
@@ -3276,9 +3293,26 @@ def addbroadcast(x, *axes):
...
@@ -3276,9 +3293,26 @@ def addbroadcast(x, *axes):
def
unbroadcast
(
x
,
*
axes
):
def
unbroadcast
(
x
,
*
axes
):
"""
"""
Make the input impossible to broadcast in the specified axes.
Make the input impossible to broadcast in the specified axes.
For example, addbroadcast(x, 0) will make the first dimension
of x broadcastable. When performing the function, if the length
of x along that dimension is not 1, a ValueError will be raised.
We apply the opt here not to pollute the graph especially during
We apply the opt here not to pollute the graph especially during
the gpu optimization
the gpu optimization
Parameters:
------------
x : tensor_like
Input theano tensor.
axis : an int or an iterable object such as list or tuple
of int values
The dimension along which the tensor x should be unbroadcastable.
if the length of x along these dimensions is not 1,
a ValueError will be raised.
returns:
----------
a theano tensor, which is unbroadcastable along the specified dimensions.
"""
"""
rval
=
Rebroadcast
(
*
[(
axis
,
False
)
for
axis
in
axes
])(
x
)
rval
=
Rebroadcast
(
*
[(
axis
,
False
)
for
axis
in
axes
])(
x
)
return
theano
.
tensor
.
opt
.
apply_rebroadcast_opt
(
rval
)
return
theano
.
tensor
.
opt
.
apply_rebroadcast_opt
(
rval
)
...
@@ -3287,9 +3321,28 @@ def unbroadcast(x, *axes):
...
@@ -3287,9 +3321,28 @@ def unbroadcast(x, *axes):
def
patternbroadcast
(
x
,
broadcastable
):
def
patternbroadcast
(
x
,
broadcastable
):
"""
"""
Make the input adopt a specific broadcasting pattern.
Make the input adopt a specific broadcasting pattern.
broadcastable must be iterable. For example,
patternbroadcast(x, (True, False)) will make the first
dimension of x broadcastable and the second dimension
not broadcastable, so x will now be a row.
We apply the opt here not to pollute the graph especially during the gpu
We apply the opt here not to pollute the graph especially during the gpu
optimization.
optimization.
Parameters:
------------
x : tensor_like
Input theano tensor.
broadcastable : an iterable object such as list or tuple
of bool values
a set of boolean values indicating whether a dimension
should be broadcastable or not.
if the length of x along these dimensions is not 1,
a ValueError will be raised.
returns:
----------
a theano tensor, which is unbroadcastable along the specified dimensions.
"""
"""
rval
=
Rebroadcast
(
*
[(
i
,
broadcastable
[
i
])
rval
=
Rebroadcast
(
*
[(
i
,
broadcastable
[
i
])
for
i
in
xrange
(
len
(
broadcastable
))])(
x
)
for
i
in
xrange
(
len
(
broadcastable
))])(
x
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论