Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f3d712ef
提交
f3d712ef
authored
8月 10, 2017
作者:
AndreiCostinescu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Changed comments to docstrings where necessary in theano/tensor/tests
上级
3b205e97
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
112 行增加
和
95 行删除
+112
-95
mlp_test.py
theano/tensor/tests/mlp_test.py
+0
-1
test_blas.py
theano/tensor/tests/test_blas.py
+8
-5
test_blas_c.py
theano/tensor/tests/test_blas_c.py
+5
-3
test_inc_subtensor.py
theano/tensor/tests/test_inc_subtensor.py
+14
-13
test_nlinalg.py
theano/tensor/tests/test_nlinalg.py
+14
-13
test_opt.py
theano/tensor/tests/test_opt.py
+32
-23
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+30
-29
test_subtensor.py
theano/tensor/tests/test_subtensor.py
+9
-8
没有找到文件。
theano/tensor/tests/mlp_test.py
浏览文件 @
f3d712ef
...
...
@@ -23,7 +23,6 @@ def gen_data():
np
.
asarray
(
np
.
random
.
rand
(
10000
)
*
10
,
dtype
=
'int64'
))
test_set
=
(
np
.
asarray
(
np
.
random
.
rand
(
10000
,
784
),
dtype
=
'float32'
),
np
.
asarray
(
np
.
random
.
rand
(
10000
)
*
10
,
dtype
=
'int64'
))
def
shared_dataset
(
data_xy
):
""" Function that loads the dataset into shared variables
...
...
theano/tensor/tests/test_blas.py
浏览文件 @
f3d712ef
...
...
@@ -46,8 +46,9 @@ def sharedX(x, name):
class
t_gemm
(
TestCase
):
# This test suite is supposed to establish that gemm works as it
# is supposed to.
"""
This test suite is supposed to establish that gemm works as it is supposed to.
"""
def
setUp
(
self
):
unittest_tools
.
seed_rng
()
...
...
@@ -437,9 +438,11 @@ def fail(msg):
assert
False
# This test suite ensures that Gemm is inserted where it belongs, and
# that the resulting functions compute the same things as the
# originals.
"""
This test suite ensures that Gemm is inserted where it belongs, and
that the resulting functions compute the same things as the originals.
"""
def
XYZab
():
return
T
.
matrix
(),
T
.
matrix
(),
T
.
matrix
(),
T
.
scalar
(),
T
.
scalar
()
...
...
theano/tensor/tests/test_blas_c.py
浏览文件 @
f3d712ef
...
...
@@ -115,10 +115,12 @@ class TestCGer(TestCase, TestOptimizationMixin):
class
TestCGemv
(
TestCase
,
TestOptimizationMixin
):
# Tests of CGemv specifically.
# Generic tests of Gemv-compatibility, including both dtypes are
# done below in TestCGemvFloat32 and TestCGemvFloat64
"""
Tests of CGemv specifically.
Generic tests of Gemv-compatibility, including both dtypes are
done below in TestCGemvFloat32 and TestCGemvFloat64
"""
def
setUp
(
self
,
dtype
=
'float64'
):
# This tests can run even when theano.config.blas.ldflags is empty.
self
.
dtype
=
dtype
...
...
theano/tensor/tests/test_inc_subtensor.py
浏览文件 @
f3d712ef
...
...
@@ -7,19 +7,20 @@ import theano.tensor as tt
class
Test_inc_subtensor
(
unittest
.
TestCase
):
# Partial testing.
#
# What could be tested:
# - increment vs set
# - thing incremented: scalar, vector, matrix,
# - increment/set: constant, scalar, vector, matrix
# - indices: scalar vs slice, constant vs variable, out of bound, ...
# - inplace
#
# NOTE: these are the same tests as test_incsubtensor.py, but using
# the new (read: not deprecated) inc_subtensor, set_subtensor
# functions.
"""
Partial testing.
What could be tested:
- increment vs set
- thing incremented: scalar, vector, matrix,
- increment/set: constant, scalar, vector, matrix
- indices: scalar vs slice, constant vs variable, out of bound, ...
- inplace
NOTE: these are the same tests as test_incsubtensor.py, but using
the new (read: not deprecated) inc_subtensor, set_subtensor
functions.
"""
def
setUp
(
self
):
utt
.
seed_rng
()
...
...
theano/tensor/tests/test_nlinalg.py
浏览文件 @
f3d712ef
...
...
@@ -276,19 +276,20 @@ def test_det_shape():
class
test_diag
(
unittest
.
TestCase
):
# Test that linalg.diag has the same behavior as numpy.diag.
# numpy.diag has two behaviors:
# (1) when given a vector, it returns a matrix with that vector as the
# diagonal.
# (2) when given a matrix, returns a vector which is the diagonal of the
# matrix.
#
# (1) and (2) are tested by test_alloc_diag and test_extract_diag
# respectively.
#
# test_diag test makes sure that linalg.diag instantiates
# the right op based on the dimension of the input.
"""
Test that linalg.diag has the same behavior as numpy.diag.
numpy.diag has two behaviors:
(1) when given a vector, it returns a matrix with that vector as the
diagonal.
(2) when given a matrix, returns a vector which is the diagonal of the
matrix.
(1) and (2) are tested by test_alloc_diag and test_extract_diag
respectively.
test_diag test makes sure that linalg.diag instantiates
the right op based on the dimension of the input.
"""
def
__init__
(
self
,
name
,
mode
=
None
,
shared
=
tensor
.
_shared
,
floatX
=
None
,
type
=
tensor
.
TensorType
):
self
.
mode
=
mode
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
f3d712ef
...
...
@@ -904,10 +904,11 @@ class test_fusion(unittest.TestCase):
topo_exclude
=
()
def
do
(
self
,
mode
,
shared_fn
,
shp
,
nb_repeat
=
1
,
assert_len_topo
=
True
,
slice
=
None
):
# param shared_fn: if None, will use compile.function
# verify that the elemwise fusion work
# Test with and without DimShuffle
"""
param shared_fn: if None, will use compile.function
verify that the elemwise fusion work
Test with and without DimShuffle
"""
# TODO: disable the canonizer?
def
my_init
(
shp
,
dtype
=
'float64'
,
num
=
0
):
ret
=
np
.
zeros
(
shp
,
dtype
=
dtype
)
+
num
...
...
@@ -1217,8 +1218,10 @@ class test_fusion(unittest.TestCase):
dlogp
(
2
,
np
.
random
.
rand
(
n
))
def
speed_fusion
(
self
,
s
=
None
):
# param type s: a slice object
# param s: a slice to apply to the case to execute. If None, exec all case.
"""
param type s: a slice object
param s: a slice to apply to the case to execute. If None, exec all case.
"""
shp
=
(
3000
,
3000
)
shp
=
(
1000
,
1000
)
...
...
@@ -1274,10 +1277,12 @@ class test_fusion(unittest.TestCase):
class
TimesN
(
theano
.
scalar
.
basic
.
UnaryScalarOp
):
# Used in test TestCompositeCodegen
# Must be outside of the class, otherwise, the c cache code can't
# pickle this class and this cause stuff printing during test.
"""
Used in test TestCompositeCodegen
Must be outside of the class, otherwise, the c cache code can't
pickle this class and this cause stuff printing during test.
"""
def
__eq__
(
self
,
other
):
return
super
(
TimesN
,
self
)
.
__eq__
(
other
)
and
self
.
n
==
other
.
n
...
...
@@ -1304,9 +1309,10 @@ class TimesN(theano.scalar.basic.UnaryScalarOp):
class
TestCompositeCodegen
(
unittest
.
TestCase
):
# Test The Composite Ops code generation in a case where there is multiple
# scalar ops with support code.
"""
Test The Composite Ops code generation in a case where there is multiple
scalar ops with support code.
"""
def
setUp
(
self
):
upgrade_to_float
=
theano
.
scalar
.
basic
.
upgrade_to_float
...
...
@@ -3911,12 +3917,13 @@ class test_shapeoptimizer(unittest.TestCase):
@staticmethod
def
max_pool_c01b
(
c01b
,
pool_shp
,
pool_stride
,
img_shp
):
# Like max_pool but with input using axes ('c', 0, 1, 'b')
# (Alex Krizhevsky format)
#
# pool_shp, pool_stride and img_shp are int that represent
# the same shp in x and y.
"""
Like max_pool but with input using axes ('c', 0, 1, 'b')
(Alex Krizhevsky format)
pool_shp, pool_stride and img_shp are int that represent
the same shp in x and y.
"""
mx
=
None
# Compute index in pooled space of last needed pool
...
...
@@ -4675,11 +4682,12 @@ class T_local_switch_sink(unittest.TestCase):
self
.
mode
.
check_isfinite
=
False
def
function_remove_nan
(
self
,
*
args
,
**
kwargs
):
# Wrapper around theano.function for this test.
# It disables checking
# for NaN removed by optimizations in DebugMode (it has false
# positives in that case).
"""
Wrapper around theano.function for this test.
It disables checking for NaN removed by optimizations in DebugMode
(it has false positives in that case).
"""
f
=
theano
.
function
(
*
args
,
**
kwargs
)
def
wrapped_f
(
*
args
,
**
kwargs
):
...
...
@@ -5200,8 +5208,9 @@ class test_local_merge_switch_same_cond(unittest.TestCase):
class
T_local_sum_prod
(
unittest
.
TestCase
):
# Test sum/prod opts in opt.py
"""
Test sum/prod opts in opt.py
"""
def
setUp
(
self
):
self
.
mode
=
theano
.
compile
.
get_default_mode
()
.
including
(
'canonicalize'
,
'specialize'
)
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
f3d712ef
...
...
@@ -29,35 +29,36 @@ def makeSharedTester(shared_constructor_,
cast_value_
=
np
.
asarray
,
expect_fail_fast_shape_inplace
=
True
,
):
# This is a generic fct to allow reusing the same test function
# for many shared variable of many types.
#
# :param shared_constructor_: The shared variable constructor to use
# :param dtype_: The dtype of the data to test
# :param get_value_borrow_true_alias_: Should a get_value(borrow=True) return the internal object
# :param shared_borrow_true_alias_: Should shared(val,borrow=True) reuse the val memory space
# :param set_value_borrow_true_alias_: Should set_value(val,borrow=True) reuse the val memory space
# :param set_value_inplace_: Should this shared variable overwrite the current
# memory when the new value is an ndarray
# :param set_cast_value_inplace_: Should this shared variable overwrite the
# current memory when the new value is of the same
# type as the internal type.
# :param shared_constructor_accept_ndarray_: Do the shared_constructor accept an ndarray as input?
# :param internal_type_: The internal type used.
# :param test_internal_type_: A function that tell if its input is of the same
# type as this shared variable internal type.
# :param theano_fct_: A theano op that will be used to do some computation on the shared variable
# :param ref_fct_: A reference function that should return the same value as the theano_fct_
# :param cast_value_: A callable that cast an ndarray into the internal shared variable representation
# :param name: This string is used to set the returned class' __name__
# attribute. This is needed for nosetests to properly tag the
# test with its correct name, rather than use the generic
# SharedTester name. This parameter is mandatory (keeping the
# default None value will raise an error), and must be set to
# the name of the variable that will hold the returned class.
# :note:
# We must use /= as sparse type don't support other inplace operation.
"""
This is a generic fct to allow reusing the same test function
for many shared variable of many types.
:param shared_constructor_: The shared variable constructor to use
:param dtype_: The dtype of the data to test
:param get_value_borrow_true_alias_: Should a get_value(borrow=True) return the internal object
:param shared_borrow_true_alias_: Should shared(val,borrow=True) reuse the val memory space
:param set_value_borrow_true_alias_: Should set_value(val,borrow=True) reuse the val memory space
:param set_value_inplace_: Should this shared variable overwrite the current
memory when the new value is an ndarray
:param set_cast_value_inplace_: Should this shared variable overwrite the
current memory when the new value is of the same
type as the internal type.
:param shared_constructor_accept_ndarray_: Do the shared_constructor accept an ndarray as input?
:param internal_type_: The internal type used.
:param test_internal_type_: A function that tell if its input is of the same
type as this shared variable internal type.
:param theano_fct_: A theano op that will be used to do some computation on the shared variable
:param ref_fct_: A reference function that should return the same value as the theano_fct_
:param cast_value_: A callable that cast an ndarray into the internal shared variable representation
:param name: This string is used to set the returned class' __name__
attribute. This is needed for nosetests to properly tag the
test with its correct name, rather than use the generic
SharedTester name. This parameter is mandatory (keeping the
default None value will raise an error), and must be set to
the name of the variable that will hold the returned class.
:note:
We must use /= as sparse type don't support other inplace operation.
"""
class
m
(
type
):
pass
...
...
theano/tensor/tests/test_subtensor.py
浏览文件 @
f3d712ef
...
...
@@ -45,9 +45,9 @@ else:
class
T_subtensor
(
unittest
.
TestCase
,
utt
.
TestOptimizationMixin
):
# This is build in a way that allow to reuse it to test the
#
equivalent gpu op.
"""
This is build in a way that allow to reuse it to test the
equivalent gpu op.
"""
def
__init__
(
self
,
name
,
shared
=
tensor
.
_shared
,
sub
=
tensor
.
Subtensor
,
inc_sub
=
tensor
.
IncSubtensor
,
...
...
@@ -84,12 +84,13 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
def
function
(
self
,
inputs
,
outputs
,
accept_inplace
=
False
,
op
=
None
,
mode
=
None
,
N
=
1
,
N_fast
=
None
):
# wrapper around theano.function that also check the output
#
# :param N: the number of op expected in the toposort
# if tuple of length 2, (expected if fast_compile,
# if not fast_compile)
"""
wrapper around theano.function that also check the output
:param N: the number of op expected in the toposort
if tuple of length 2, (expected if fast_compile,
if not fast_compile)
"""
if
self
.
fast_compile
and
N_fast
is
not
None
:
N
=
N_fast
if
mode
is
None
:
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论