Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
967a6382
提交
967a6382
authored
8月 04, 2017
作者:
yikang
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Convert the docstrings to comments in compile/tests
上级
b7b5dd39
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
35 行增加
和
59 行删除
+35
-59
test_function_module.py
theano/compile/tests/test_function_module.py
+11
-23
test_monitormode.py
theano/compile/tests/test_monitormode.py
+3
-9
test_pfunc.py
theano/compile/tests/test_pfunc.py
+19
-21
test_profiling.py
theano/compile/tests/test_profiling.py
+2
-6
没有找到文件。
theano/compile/tests/test_function_module.py
浏览文件 @
967a6382
...
...
@@ -337,10 +337,8 @@ class T_function(unittest.TestCase):
second_time
=
True
def
test_swap_SharedVariable_with_given
(
self
):
"""
A special testcase for logistic_sgd.py in Deep Learning Tutorial
This test assert that SharedVariable in different function have same storage
"""
# A special testcase for logistic_sgd.py in Deep Learning Tutorial
# This test assert that SharedVariable in different function have same storage
train_x
=
theano
.
shared
(
value
=
np
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
test_x
=
theano
.
shared
(
value
=
np
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
...
...
@@ -491,12 +489,10 @@ class T_function(unittest.TestCase):
assert
(
out2
==
3
)
.
all
()
def
test_borrow_input
(
self
):
"""
Tests that the contract for io.In is respected. When borrow=False, it should be
impossible for outputs to be aliased to the input variables provided by the user,
either through a view-map or a destroy map. New tests should be added in the future
when borrow=True is implemented.
"""
# Tests that the contract for io.In is respected. When borrow=False, it should be
# impossible for outputs to be aliased to the input variables provided by the user,
# either through a view-map or a destroy map. New tests should be added in the future
# when borrow=True is implemented.
a
=
T
.
dmatrix
()
aval
=
np
.
random
.
rand
(
3
,
3
)
...
...
@@ -549,17 +545,13 @@ class T_function(unittest.TestCase):
function
([
m
,
mt
],
mt
*
2
,
on_unused_input
=
'ignore'
)
def
test_givens_input_var
(
self
):
"""
Ensure error is raised when trying to replace an input variable.
"""
# Ensure error is raised when trying to replace an input variable.
x
=
T
.
scalar
(
'x'
)
y
=
x
*
2
self
.
assertRaises
(
RuntimeError
,
function
,
[
x
],
y
,
givens
=
{
x
:
x
+
1
})
def
test_free
(
self
):
"""
Make test on free() function
"""
# Make test on free() function
x
=
T
.
vector
(
'x'
)
func
=
function
([
x
],
x
+
1
)
func
.
fn
.
allow_gc
=
False
...
...
@@ -578,10 +570,8 @@ class T_function(unittest.TestCase):
assert
(
val
[
0
]
is
None
)
def
test_default_values
(
self
):
"""
Check that default values are restored
when an exception occurs in interactive mode.
"""
# Check that default values are restored
# when an exception occurs in interactive mode.
a
,
b
=
T
.
dscalars
(
'a'
,
'b'
)
c
=
a
+
b
func
=
theano
.
function
([
theano
.
In
(
a
,
name
=
'first'
),
theano
.
In
(
b
,
value
=
1
,
name
=
'second'
)],
c
)
...
...
@@ -896,9 +886,7 @@ class SomethingToPickle(object):
def
test_empty_givens_updates
():
"""
Regression test for bug fixed in 8625e03.
"""
# Regression test for bug fixed in 8625e03.
# Empty givens / updates dictionaries were not properly detected before,
# triggering useless crashes at compile time.
x
=
T
.
scalar
()
...
...
theano/compile/tests/test_monitormode.py
浏览文件 @
967a6382
...
...
@@ -5,9 +5,7 @@ import theano
def
test_detect_nan
():
"""
Test the code snippet example that detects NaN values.
"""
# Test the code snippet example that detects NaN values.
nan_detected
=
[
False
]
def
detect_nan
(
i
,
node
,
fn
):
...
...
@@ -29,9 +27,7 @@ def test_detect_nan():
def
test_optimizer
():
"""
Test that we can remove optimizer
"""
# Test that we can remove optimizer
nan_detected
=
[
False
]
def
detect_nan
(
i
,
node
,
fn
):
...
...
@@ -58,9 +54,7 @@ def test_optimizer():
def
test_not_inplace
():
"""
Test that we can remove optimizers including inplace optimizers
"""
# Test that we can remove optimizers including inplace optimizers
nan_detected
=
[
False
]
def
detect_nan
(
i
,
node
,
fn
):
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
967a6382
...
...
@@ -15,14 +15,14 @@ from theano.compile import config
def
data_of
(
s
):
"""Return the raw value of a shared variable"""
# Return the raw value of a shared variable
return
s
.
container
.
storage
[
0
]
class
Test_pfunc
(
unittest
.
TestCase
):
def
test_doc
(
self
):
"""Ensure the code given in pfunc.txt works as expected"""
# Ensure the code given in pfunc.txt works as expected
# Example #1.
a
=
lscalar
()
...
...
@@ -74,7 +74,7 @@ class Test_pfunc(unittest.TestCase):
assert
np
.
all
(
f1
(
xval
)
==
xval
+
w
.
get_value
(
borrow
=
True
))
def
test_no_shared_as_input
(
self
):
"""Test that shared variables cannot be used as function inputs."""
# Test that shared variables cannot be used as function inputs.
w_init
=
np
.
random
.
rand
(
2
,
2
)
w
=
shared
(
w_init
.
copy
(),
'w'
)
try
:
...
...
@@ -317,7 +317,7 @@ class Test_pfunc(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
h
,
0.1
,
[
0
])
def
test_update
(
self
):
"""Test update mechanism in different settings."""
# Test update mechanism in different settings.
# Simple value assignment.
x
=
shared
(
0
)
...
...
@@ -666,28 +666,26 @@ class Test_pfunc(unittest.TestCase):
class
Test_aliasing_rules
(
unittest
.
TestCase
):
"""
1. Theano manages its own memory space, which typically does not overlap
with the memory of normal python variables that the user uses.
# 1. Theano manages its own memory space, which typically does not overlap
# with the memory of normal python variables that the user uses.
2. shared variables are allocated in this memory space, as are the
temporaries used for Function evalution.
#
2. shared variables are allocated in this memory space, as are the
#
temporaries used for Function evalution.
3. Physically, this managed memory space may be spread across the host,
on a GPU device(s), or even on a remote machine.
#
3. Physically, this managed memory space may be spread across the host,
#
on a GPU device(s), or even on a remote machine.
4. Theano assumes that shared variables are never aliased to one another,
and tries to make it impossible to accidentally alias them.
#
4. Theano assumes that shared variables are never aliased to one another,
#
and tries to make it impossible to accidentally alias them.
5. Theano's managed data is constant while Theano Functions are not running
and theano library code is not running.
#
5. Theano's managed data is constant while Theano Functions are not running
#
and theano library code is not running.
6. The default behaviour of Function is to return user-space values for
outputs, but this can be overridden (borrow=True) for better performance,
in which case the returned value may be aliased to managed memory, and
potentially invalidated by the next Theano Function call or call to theano
library code.
"""
# 6. The default behaviour of Function is to return user-space values for
# outputs, but this can be overridden (borrow=True) for better performance,
# in which case the returned value may be aliased to managed memory, and
# potentially invalidated by the next Theano Function call or call to theano
# library code.
def
shared
(
self
,
x
):
return
tensor
.
_shared
(
x
)
...
...
theano/compile/tests/test_profiling.py
浏览文件 @
967a6382
"""
Test of memory profiling
# Test of memory profiling
"""
from
__future__
import
absolute_import
,
print_function
,
division
import
unittest
...
...
@@ -15,9 +13,7 @@ from theano.ifelse import ifelse
class
Test_profiling
(
unittest
.
TestCase
):
"""
Test of Theano profiling with min_peak_memory=True
"""
# Test of Theano profiling with min_peak_memory=True
def
test_profiling
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论