Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
193c9979
提交
193c9979
authored
11月 30, 2016
作者:
Gijs van Tulder
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
assert_conv_shape resolves constants.
上级
beded2b3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
23 行增加
和
9 行删除
+23
-9
abstract_conv.py
theano/tensor/nnet/abstract_conv.py
+23
-9
没有找到文件。
theano/tensor/nnet/abstract_conv.py
浏览文件 @
193c9979
...
@@ -432,6 +432,9 @@ def check_conv_gradinputs_shape(image_shape, kernel_shape, output_shape,
...
@@ -432,6 +432,9 @@ def check_conv_gradinputs_shape(image_shape, kernel_shape, output_shape,
def
assert_conv_shape
(
shape
):
def
assert_conv_shape
(
shape
):
"""This function adds Assert nodes that check if shape is a valid convolution shape.
"""This function adds Assert nodes that check if shape is a valid convolution shape.
The first two dimensions should be larger than or equal to zero. The convolution
dimensions should be larger than zero.
Parameters
Parameters
----------
----------
shape: tuple of int (symbolic or numeric) corresponding to the input, output or
shape: tuple of int (symbolic or numeric) corresponding to the input, output or
...
@@ -442,18 +445,29 @@ def assert_conv_shape(shape):
...
@@ -442,18 +445,29 @@ def assert_conv_shape(shape):
Returns
Returns
-------
-------
Returns a tuple similar to the given `shape`, but with each element wrapped in
Returns a tuple similar to the given `shape`. For constant elements in `shape`,
an `Assert` op that checks that dimension. The first two dimensions should be
the function checks the value and raises a `ValueError` if the dimension is invalid.
larger than or equal to zero. The convolution dimensions should be larger than zero.
The elements that are not constant are wrapped in an `Assert` op that checks the
dimension at run time.
"""
"""
out_shape
=
[]
out_shape
=
[]
for
i
,
n
in
enumerate
(
shape
):
for
i
,
n
in
enumerate
(
shape
):
if
i
<
2
:
try
:
assert_shp
=
Assert
(
'The convolution would produce an invalid shape (dim[
%
d] < 0).'
%
i
)
const_n
=
get_scalar_constant_value
(
n
)
out_shape
.
append
(
assert_shp
(
n
,
theano
.
tensor
.
ge
(
n
,
0
)))
if
i
<
2
:
else
:
if
const_n
<
0
:
assert_shp
=
Assert
(
'The convolution would produce an invalid shape (dim[
%
d] <= 0).'
%
i
)
raise
ValueError
(
'The convolution would produce an invalid shape (dim[
%
d]:
%
d < 0).'
%
(
i
,
const_n
))
out_shape
.
append
(
assert_shp
(
n
,
theano
.
tensor
.
gt
(
n
,
0
)))
else
:
if
const_n
<=
0
:
raise
ValueError
(
'The convolution would produce an invalid shape (dim[
%
d]:
%
d <= 0).'
%
(
i
,
const_n
))
out_shape
.
append
(
n
)
except
NotScalarConstantError
:
if
i
<
2
:
assert_shp
=
Assert
(
'The convolution would produce an invalid shape (dim[
%
d] < 0).'
%
i
)
out_shape
.
append
(
assert_shp
(
n
,
theano
.
tensor
.
ge
(
n
,
0
)))
else
:
assert_shp
=
Assert
(
'The convolution would produce an invalid shape (dim[
%
d] <= 0).'
%
i
)
out_shape
.
append
(
assert_shp
(
n
,
theano
.
tensor
.
gt
(
n
,
0
)))
return
tuple
(
out_shape
)
return
tuple
(
out_shape
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论