Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
9a203db3
提交
9a203db3
authored
8月 17, 2016
作者:
Frédéric Bastien
提交者:
GitHub
8月 17, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4866 from lamblin/fix_jenkins
Fix jenkins
上级
87514c0d
4de5d0c5
隐藏空白字符变更
内嵌
并排
正在显示
7 个修改的文件
包含
41 行增加
和
20 行删除
+41
-20
test_subtensor.py
theano/gpuarray/tests/test_subtensor.py
+2
-0
gradient.py
theano/gradient.py
+5
-2
test_basic_ops.py
theano/sandbox/cuda/tests/test_basic_ops.py
+2
-1
test_tensor_op.py
theano/sandbox/cuda/tests/test_tensor_op.py
+7
-3
test_conv3d2d.py
theano/tensor/nnet/tests/test_conv3d2d.py
+9
-1
test_basic.py
theano/tensor/tests/test_basic.py
+1
-1
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+15
-12
没有找到文件。
theano/gpuarray/tests/test_subtensor.py
浏览文件 @
9a203db3
...
@@ -7,6 +7,7 @@ from theano.compile import DeepCopyOp
...
@@ -7,6 +7,7 @@ from theano.compile import DeepCopyOp
from
theano.tensor.tests
import
test_subtensor
from
theano.tensor.tests
import
test_subtensor
from
..basic_ops
import
HostFromGpu
,
GpuFromHost
from
..basic_ops
import
HostFromGpu
,
GpuFromHost
from
..elemwise
import
GpuDimShuffle
from
..subtensor
import
(
GpuIncSubtensor
,
GpuSubtensor
,
from
..subtensor
import
(
GpuIncSubtensor
,
GpuSubtensor
,
GpuAdvancedSubtensor1
,
GpuAdvancedSubtensor1
,
GpuAdvancedIncSubtensor1
)
GpuAdvancedIncSubtensor1
)
...
@@ -27,6 +28,7 @@ class G_subtensor(test_subtensor.T_subtensor):
...
@@ -27,6 +28,7 @@ class G_subtensor(test_subtensor.T_subtensor):
inc_sub
=
GpuIncSubtensor
,
inc_sub
=
GpuIncSubtensor
,
adv_sub1
=
GpuAdvancedSubtensor1
,
adv_sub1
=
GpuAdvancedSubtensor1
,
adv_incsub1
=
GpuAdvancedIncSubtensor1
,
adv_incsub1
=
GpuAdvancedIncSubtensor1
,
dimshuffle
=
GpuDimShuffle
,
mode
=
mode_with_gpu
,
mode
=
mode_with_gpu
,
# avoid errors with limited devices
# avoid errors with limited devices
dtype
=
'float32'
,
dtype
=
'float32'
,
...
...
theano/gradient.py
浏览文件 @
9a203db3
...
@@ -1369,8 +1369,10 @@ class numeric_grad(object):
...
@@ -1369,8 +1369,10 @@ class numeric_grad(object):
# perfectly accurate.
# perfectly accurate.
type_eps
=
{
'float64'
:
1e-7
,
type_eps
=
{
'float64'
:
1e-7
,
'float32'
:
3e-4
,
'float32'
:
3e-4
,
'float16'
:
1e-3
,
numpy
.
dtype
(
'float64'
):
1e-7
,
numpy
.
dtype
(
'float64'
):
1e-7
,
numpy
.
dtype
(
'float32'
):
3e-4
}
numpy
.
dtype
(
'float32'
):
3e-4
,
numpy
.
dtype
(
'float16'
):
1e-3
}
def
__init__
(
self
,
f
,
pt
,
eps
=
None
,
out_type
=
None
):
def
__init__
(
self
,
f
,
pt
,
eps
=
None
,
out_type
=
None
):
"""Return the gradient of f at pt.
"""Return the gradient of f at pt.
...
@@ -1606,12 +1608,13 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
...
@@ -1606,12 +1608,13 @@ def verify_grad(fun, pt, n_tests=2, rng=None, eps=None,
pt
=
[
numpy
.
array
(
p
)
for
p
in
pt
]
pt
=
[
numpy
.
array
(
p
)
for
p
in
pt
]
for
i
,
p
in
enumerate
(
pt
):
for
i
,
p
in
enumerate
(
pt
):
if
p
.
dtype
not
in
(
'float32'
,
'float64'
):
if
p
.
dtype
not
in
(
'float
16'
,
'float
32'
,
'float64'
):
raise
TypeError
(
raise
TypeError
(
(
'verify_grad can work only with floating point '
(
'verify_grad can work only with floating point '
'inputs, but input
%
i has dtype "
%
s".'
)
%
(
i
,
p
.
dtype
))
'inputs, but input
%
i has dtype "
%
s".'
)
%
(
i
,
p
.
dtype
))
_type_tol
=
dict
(
# relative error tolerances for different types
_type_tol
=
dict
(
# relative error tolerances for different types
float16
=
5e-2
,
float32
=
1e-2
,
float32
=
1e-2
,
float64
=
1e-4
)
float64
=
1e-4
)
...
...
theano/sandbox/cuda/tests/test_basic_ops.py
浏览文件 @
9a203db3
...
@@ -1014,6 +1014,7 @@ class T_subtensor(theano.tensor.tests.test_subtensor.T_subtensor):
...
@@ -1014,6 +1014,7 @@ class T_subtensor(theano.tensor.tests.test_subtensor.T_subtensor):
inc_sub
=
cuda
.
GpuIncSubtensor
inc_sub
=
cuda
.
GpuIncSubtensor
adv_sub1
=
cuda
.
GpuAdvancedSubtensor1
adv_sub1
=
cuda
.
GpuAdvancedSubtensor1
adv_incsub1
=
cuda
.
GpuAdvancedIncSubtensor1
adv_incsub1
=
cuda
.
GpuAdvancedIncSubtensor1
dimshuffle
=
cuda
.
GpuDimShuffle
mode
=
mode_with_gpu
mode
=
mode_with_gpu
dtype
=
'float32'
dtype
=
'float32'
type
=
tcn
.
CudaNdarrayType
type
=
tcn
.
CudaNdarrayType
...
@@ -1075,7 +1076,7 @@ class T_subtensor(theano.tensor.tests.test_subtensor.T_subtensor):
...
@@ -1075,7 +1076,7 @@ class T_subtensor(theano.tensor.tests.test_subtensor.T_subtensor):
# Test with c_contiguous input
# Test with c_contiguous input
t
=
self
.
adv_sub1
()(
n
,
idx
)
t
=
self
.
adv_sub1
()(
n
,
idx
)
t
.
owner
.
op
.
perform_using_take
=
True
# input c_contiguous, so we reshape
t
.
owner
.
op
.
perform_using_take
=
True
# input c_contiguous, so we reshape
val
=
self
.
eval_output_and_check
(
t
,
list
=
True
)
val
=
self
.
eval_output_and_check
(
t
,
op_type
=
self
.
adv_sub1
)
val
=
numpy
.
asarray
(
val
)
val
=
numpy
.
asarray
(
val
)
good
=
data
[
idx
]
good
=
data
[
idx
]
...
...
theano/sandbox/cuda/tests/test_tensor_op.py
浏览文件 @
9a203db3
...
@@ -3,12 +3,14 @@ This file test tensor op that should also operate on CudaNdaray.
...
@@ -3,12 +3,14 @@ This file test tensor op that should also operate on CudaNdaray.
"""
"""
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
from
nose.plugins.skip
import
SkipTest
from
nose.plugins.skip
import
SkipTest
from
nose_parameterized
import
parameterized
import
numpy
import
numpy
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
import
theano.tensor
as
T
import
theano.tensor
as
T
import
theano.tests.unittest_tools
as
utt
# Skip test if cuda_ndarray is not available.
# Skip test if cuda_ndarray is not available.
import
theano.sandbox.cuda
as
cuda
import
theano.sandbox.cuda
as
cuda
...
@@ -139,6 +141,8 @@ def test_get_diagonal_subtensor_view():
...
@@ -139,6 +141,8 @@ def test_get_diagonal_subtensor_view():
test_conv3d2d
.
test_get_diagonal_subtensor_view
(
wrap
=
cuda
.
CudaNdarray
)
test_conv3d2d
.
test_get_diagonal_subtensor_view
(
wrap
=
cuda
.
CudaNdarray
)
def
test_conv3d
():
@parameterized.expand
((
'valid'
,
'full'
),
utt
.
custom_name_func
)
test_conv3d2d
.
test_conv3d
(
mode
=
mode_with_gpu
,
def
test_conv3d
(
border_mode
):
shared
=
cuda
.
shared_constructor
)
test_conv3d2d
.
check_conv3d
(
border_mode
=
border_mode
,
mode
=
mode_with_gpu
,
shared
=
cuda
.
shared_constructor
)
theano/tensor/nnet/tests/test_conv3d2d.py
浏览文件 @
9a203db3
...
@@ -92,7 +92,15 @@ def check_diagonal_subtensor_view_traces(fn):
...
@@ -92,7 +92,15 @@ def check_diagonal_subtensor_view_traces(fn):
@parameterized.expand
((
'valid'
,
'full'
),
utt
.
custom_name_func
)
@parameterized.expand
((
'valid'
,
'full'
),
utt
.
custom_name_func
)
def
test_conv3d
(
border_mode
,
mode
=
mode_without_gpu
,
shared
=
theano
.
tensor
.
_shared
):
def
test_conv3d
(
border_mode
):
check_conv3d
(
border_mode
=
border_mode
,
mode
=
mode_without_gpu
,
shared
=
theano
.
tensor
.
_shared
)
# This function will also be used in theano/sandbox/cuda/tests/test_tensor_op.py,
# which is not possible if it is decorated by @parameterized.expand
def
check_conv3d
(
border_mode
,
mode
=
mode_without_gpu
,
shared
=
theano
.
tensor
.
_shared
):
if
ndimage
is
None
:
if
ndimage
is
None
:
raise
SkipTest
(
"conv3d2d tests need SciPy"
)
raise
SkipTest
(
"conv3d2d tests need SciPy"
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
9a203db3
...
@@ -1649,7 +1649,7 @@ TanhInplaceTester = makeBroadcastTester(
...
@@ -1649,7 +1649,7 @@ TanhInplaceTester = makeBroadcastTester(
grad
=
_grad_broadcast_unary_normal
,
grad
=
_grad_broadcast_unary_normal
,
inplace
=
True
)
inplace
=
True
)
_eps
=
1e-
10
_eps
=
1e-
2
_good_broadcast_unary_arctanh
=
dict
(
_good_broadcast_unary_arctanh
=
dict
(
normal
=
(
rand_ranged
(
-
1
+
_eps
,
1
-
_eps
,
(
2
,
3
)),),
normal
=
(
rand_ranged
(
-
1
+
_eps
,
1
-
_eps
,
(
2
,
3
)),),
integers
=
(
randint_ranged
(
-
1
+
_eps
,
1
-
_eps
,
(
2
,
3
)),),
integers
=
(
randint_ranged
(
-
1
+
_eps
,
1
-
_eps
,
(
2
,
3
)),),
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
9a203db3
...
@@ -58,12 +58,14 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -58,12 +58,14 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
mode
=
None
,
mode
=
None
,
dtype
=
theano
.
config
.
floatX
,
dtype
=
theano
.
config
.
floatX
,
type
=
tensor
.
TensorType
,
type
=
tensor
.
TensorType
,
ignore_topo
=
DeepCopyOp
):
ignore_topo
=
DeepCopyOp
,
dimshuffle
=
DimShuffle
):
self
.
shared
=
shared
self
.
shared
=
shared
self
.
sub
=
sub
self
.
sub
=
sub
self
.
inc_sub
=
inc_sub
self
.
inc_sub
=
inc_sub
self
.
adv_sub1
=
adv_sub1
self
.
adv_sub1
=
adv_sub1
self
.
adv_incsub1
=
adv_incsub1
self
.
adv_incsub1
=
adv_incsub1
self
.
dimshuffle
=
dimshuffle
if
mode
is
None
:
if
mode
is
None
:
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
mode
=
theano
.
compile
.
mode
.
get_default_mode
()
mode
=
mode
.
including
(
"local_useless_subtensor"
)
mode
=
mode
.
including
(
"local_useless_subtensor"
)
...
@@ -343,28 +345,29 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
...
@@ -343,28 +345,29 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
numpy_n
=
numpy
.
arange
(
24
,
dtype
=
self
.
dtype
)
.
reshape
((
2
,
3
,
4
))
numpy_n
=
numpy
.
arange
(
24
,
dtype
=
self
.
dtype
)
.
reshape
((
2
,
3
,
4
))
n
=
self
.
shared
(
numpy_n
)
n
=
self
.
shared
(
numpy_n
)
test_cases
=
[
test_cases
=
[
(
0
,
self
.
sub
,
numpy
.
index_exp
[
...
]),
(
0
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
...
]),
(
1
,
self
.
sub
,
numpy
.
index_exp
[
...
,
1
]),
(
1
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
...
,
1
]),
(
1
,
self
.
sub
,
numpy
.
index_exp
[
1
,
...
]),
(
1
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
1
,
...
]),
(
1
,
self
.
sub
,
numpy
.
index_exp
[
...
,
1
,
2
,
3
]),
(
1
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
...
,
1
,
2
,
3
]),
(
1
,
self
.
sub
,
numpy
.
index_exp
[
1
,
...
,
2
,
3
]),
(
1
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
1
,
...
,
2
,
3
]),
(
1
,
self
.
sub
,
numpy
.
index_exp
[
1
,
2
,
3
,
...
]),
(
1
,
Subtensor
,
self
.
sub
,
numpy
.
index_exp
[
1
,
2
,
3
,
...
]),
(
3
,
DimShuffle
,
numpy
.
index_exp
[
...
,
[
0
,
2
,
3
]]),
(
3
,
DimShuffle
,
self
.
dimshuffle
,
(
1
,
DimShuffle
,
numpy
.
index_exp
[
...
,
[
0
,
2
,
3
]]),
(
1
,
DimShuffle
,
self
.
dimshuffle
,
numpy
.
index_exp
[
numpy
.
newaxis
,
...
])]
numpy
.
index_exp
[
numpy
.
newaxis
,
...
])]
# The following test case is not supported by numpy before 1.9
# The following test case is not supported by numpy before 1.9
numpy_version
=
[
int
(
v
)
for
v
in
numpy
.
version
.
version
.
split
(
'.'
)[
0
:
2
]]
numpy_version
=
[
int
(
v
)
for
v
in
numpy
.
version
.
version
.
split
(
'.'
)[
0
:
2
]]
if
numpy_version
>=
[
1
,
9
]:
if
numpy_version
>=
[
1
,
9
]:
test_cases
.
append
(
test_cases
.
append
(
(
1
,
AdvancedSubtensor
,
(
1
,
AdvancedSubtensor
,
AdvancedSubtensor
,
numpy
.
index_exp
[
...
,
numpy
.
newaxis
,
[
1
,
2
]]))
numpy
.
index_exp
[
...
,
numpy
.
newaxis
,
[
1
,
2
]]))
for
length
,
op_type
,
slice_
in
test_cases
:
for
length
,
op_type
,
op_type_opt
,
slice_
in
test_cases
:
numpy_tval
=
numpy_n
[
slice_
]
numpy_tval
=
numpy_n
[
slice_
]
t
=
n
[
slice_
]
t
=
n
[
slice_
]
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
op_type
))
self
.
assertTrue
(
isinstance
(
t
.
owner
.
op
,
op_type
))
tval
=
self
.
eval_output_and_check
(
t
,
tval
=
self
.
eval_output_and_check
(
t
,
op_type
=
op_type
,
op_type
=
op_type
_opt
,
length
=
length
)
length
=
length
)
assert_equal
(
tval
.
shape
,
numpy_tval
.
shape
)
assert_equal
(
tval
.
shape
,
numpy_tval
.
shape
)
assert_array_equal
(
tval
,
numpy_tval
)
assert_array_equal
(
tval
,
numpy_tval
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论