Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f92e1096
提交
f92e1096
authored
12月 27, 2022
作者:
Michael Osthege
提交者:
Maxim Kochurov
12月 27, 2022
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Remove references to removed `nnet` and `signal` modules
上级
d7985536
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
4 行增加
和
117 行删除
+4
-117
test.yml
.github/workflows/test.yml
+4
-4
__init__.py
tests/tensor/signal/__init__.py
+0
-0
test_conv.py
tests/tensor/signal/test_conv.py
+0
-113
没有找到文件。
.github/workflows/test.yml
浏览文件 @
f92e1096
...
@@ -72,8 +72,8 @@ jobs:
...
@@ -72,8 +72,8 @@ jobs:
float32
:
[
0
]
float32
:
[
0
]
install-numba
:
[
1
]
install-numba
:
[
1
]
part
:
part
:
-
"
tests
--ignore=tests/tensor
--ignore=tests/sparse
--ignore=tests/tensor/nnet
--ignore=tests/tensor/signal
"
-
"
tests
--ignore=tests/tensor
--ignore=tests/sparse"
-
"
tests/tensor
tests/sparse
--ignore=tests/tensor/test_basic.py
--ignore=tests/tensor/test_math.py
--ignore=tests/tensor/test_math_scipy.py
--ignore=tests/tensor/test_inplace.py
--ignore=tests/tensor/test_elemwise.py
--ignore=tests/tensor/rewriting/test_basic.py
--ignore=tests/tensor/rewriting/test_math.py
--ignore=tests/tensor/nnet
--ignore=tests/tensor/signal
"
-
"
tests/tensor
tests/sparse
--ignore=tests/tensor/test_basic.py
--ignore=tests/tensor/test_math.py
--ignore=tests/tensor/test_math_scipy.py
--ignore=tests/tensor/test_inplace.py
--ignore=tests/tensor/test_elemwise.py
--ignore=tests/tensor/rewriting/test_basic.py
--ignore=tests/tensor/rewriting/test_math.py"
-
"
tests/tensor/test_basic.py
tests/tensor/test_math.py
tests/tensor/test_math_scipy.py
tests/tensor/test_inplace.py"
-
"
tests/tensor/test_basic.py
tests/tensor/test_math.py
tests/tensor/test_math_scipy.py
tests/tensor/test_inplace.py"
-
"
tests/tensor/test_elemwise.py
tests/tensor/rewriting/test_basic.py
tests/tensor/rewriting/test_math.py"
-
"
tests/tensor/test_elemwise.py
tests/tensor/rewriting/test_basic.py
tests/tensor/rewriting/test_math.py"
-
"
tests/tensor/conv/test_abstract_conv.py"
-
"
tests/tensor/conv/test_abstract_conv.py"
...
@@ -82,12 +82,12 @@ jobs:
...
@@ -82,12 +82,12 @@ jobs:
fast-compile
:
1
fast-compile
:
1
float32
:
1
float32
:
1
install-numba
:
1
install-numba
:
1
part
:
"
tests
--ignore=tests/tensor/nnet
--ignore=tests/tensor/signal
"
part
:
"
tests"
-
python-version
:
"
3.7"
-
python-version
:
"
3.7"
fast-compile
:
1
fast-compile
:
1
float32
:
0
float32
:
0
install-numba
:
1
install-numba
:
1
part
:
"
tests
--ignore=tests/tensor/nnet
--ignore=tests/tensor/signal
"
part
:
"
tests"
steps
:
steps
:
-
uses
:
actions/checkout@v3
-
uses
:
actions/checkout@v3
with
:
with
:
...
...
tests/tensor/signal/__init__.py
deleted
100644 → 0
浏览文件 @
d7985536
tests/tensor/signal/test_conv.py
deleted
100644 → 0
浏览文件 @
d7985536
import
numpy
as
np
import
pytest
import
pytensor
from
pytensor.tensor.math
import
_allclose
from
pytensor.tensor.signal
import
conv
from
pytensor.tensor.type
import
TensorType
,
dtensor3
,
dtensor4
,
dvector
,
matrix
from
tests
import
unittest_tools
as
utt
_
=
pytest
.
importorskip
(
"scipy.signal"
)
class
TestSignalConv2D
:
def
validate
(
self
,
image_shape
,
filter_shape
,
out_dim
,
verify_grad
=
True
):
image_dim
=
len
(
image_shape
)
filter_dim
=
len
(
filter_shape
)
input
=
TensorType
(
"float64"
,
shape
=
(
None
,)
*
image_dim
)()
filters
=
TensorType
(
"float64"
,
shape
=
(
None
,)
*
filter_dim
)()
bsize
=
image_shape
[
0
]
if
image_dim
!=
3
:
bsize
=
1
nkern
=
filter_shape
[
0
]
if
filter_dim
!=
3
:
nkern
=
1
# PYTENSOR IMPLEMENTATION ############
# we create a symbolic function so that verify_grad can work
def
sym_conv2d
(
input
,
filters
):
return
conv
.
conv2d
(
input
,
filters
)
output
=
sym_conv2d
(
input
,
filters
)
assert
output
.
ndim
==
out_dim
pytensor_conv
=
pytensor
.
function
([
input
,
filters
],
output
)
# initialize input and compute result
image_data
=
np
.
random
.
random
(
image_shape
)
filter_data
=
np
.
random
.
random
(
filter_shape
)
pytensor_output
=
pytensor_conv
(
image_data
,
filter_data
)
# REFERENCE IMPLEMENTATION ############
out_shape2d
=
np
.
array
(
image_shape
[
-
2
:])
-
np
.
array
(
filter_shape
[
-
2
:])
+
1
ref_output
=
np
.
zeros
(
tuple
(
out_shape2d
))
# reshape as 3D input tensors to make life easier
image_data3d
=
image_data
.
reshape
((
bsize
,)
+
image_shape
[
-
2
:])
filter_data3d
=
filter_data
.
reshape
((
nkern
,)
+
filter_shape
[
-
2
:])
# reshape pytensor output as 4D to make life easier
pytensor_output4d
=
pytensor_output
.
reshape
(
(
bsize
,
nkern
,
)
+
pytensor_output
.
shape
[
-
2
:]
)
# loop over mini-batches (if required)
for
b
in
range
(
bsize
):
# loop over filters (if required)
for
k
in
range
(
nkern
):
image2d
=
image_data3d
[
b
,
:,
:]
filter2d
=
filter_data3d
[
k
,
:,
:]
output2d
=
np
.
zeros
(
ref_output
.
shape
)
for
row
in
range
(
ref_output
.
shape
[
0
]):
for
col
in
range
(
ref_output
.
shape
[
1
]):
output2d
[
row
,
col
]
+=
(
image2d
[
row
:
row
+
filter2d
.
shape
[
0
],
col
:
col
+
filter2d
.
shape
[
1
],
]
*
filter2d
[::
-
1
,
::
-
1
]
)
.
sum
()
assert
_allclose
(
pytensor_output4d
[
b
,
k
,
:,
:],
output2d
)
# TEST GRADIENT ############
if
verify_grad
:
utt
.
verify_grad
(
sym_conv2d
,
[
image_data
,
filter_data
])
@pytest.mark.skipif
(
pytensor
.
config
.
cxx
==
""
,
reason
=
"conv2d tests need a c++ compiler"
,
)
def
test_basic
(
self
):
# Basic functionality of nnet.conv.ConvOp is already tested by
# its own test suite. We just have to test whether or not
# signal.conv.conv2d can support inputs and filters of type
# matrix or tensor3.
self
.
validate
((
1
,
4
,
5
),
(
2
,
2
,
3
),
out_dim
=
4
,
verify_grad
=
True
)
self
.
validate
((
7
,
5
),
(
5
,
2
,
3
),
out_dim
=
3
,
verify_grad
=
False
)
self
.
validate
((
3
,
7
,
5
),
(
2
,
3
),
out_dim
=
3
,
verify_grad
=
False
)
self
.
validate
((
7
,
5
),
(
2
,
3
),
out_dim
=
2
,
verify_grad
=
False
)
def
test_fail
(
self
):
# Test that conv2d fails for dimensions other than 2 or 3.
with
pytest
.
raises
(
Exception
):
conv
.
conv2d
(
dtensor4
(),
dtensor3
())
with
pytest
.
raises
(
Exception
):
conv
.
conv2d
(
dtensor3
(),
dvector
())
def
test_bug_josh_reported
(
self
):
# Test refers to a bug reported by Josh, when due to a bad merge these
# few lines of code failed. See
# http://groups.google.com/group/theano-dev/browse_thread/thread/8856e7ca5035eecb
m1
=
matrix
()
m2
=
matrix
()
conv
.
conv2d
(
m1
,
m2
)
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论