Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
c8615bdc
提交
c8615bdc
authored
3月 29, 2012
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Update test T_subtensor.test_advanced_inc_and_set to work correctly.
上级
2c8c27d3
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
18 行增加
和
12 行删除
+18
-12
test_basic.py
theano/tensor/tests/test_basic.py
+18
-12
没有找到文件。
theano/tensor/tests/test_basic.py
浏览文件 @
c8615bdc
...
...
@@ -2100,23 +2100,20 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
return
super
(
T_subtensor
,
self
)
.
__init__
(
name
)
def
function
(
self
,
inputs
,
outputs
,
accept_inplace
=
False
,
op
=
None
,
mode
=
None
,
N
=
1
):
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)
"""
if
isinstance
(
N
,
tuple
):
assert
len
(
N
)
==
2
if
self
.
fast_compile
:
N
=
N
[
0
]
else
:
N
=
N
[
1
]
if
self
.
fast_compile
and
N_fast
is
not
None
:
N
=
N_fast
if
mode
is
None
:
mode
=
self
.
mode
if
op
is
None
:
op
=
self
.
sub
f
=
theano
.
function
(
inputs
,
outputs
,
mode
=
mode
,
accept_inplace
=
accept_inplace
)
self
.
assertFunctionContainsClassN
(
f
,
op
,
N
)
...
...
@@ -2694,7 +2691,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
if
idx
is
idxs
[
0
]:
f
=
self
.
function
([],
[
gn
.
shape
,
n
[
idx_
]
.
shape
],
op
=
ops
,
N
=
(
2
,
0
)
)
N
=
0
,
N_fast
=
2
)
f
()
def
test_wrong_exception_regression
(
self
):
...
...
@@ -2747,7 +2744,7 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
data
=
numpy
.
asarray
(
data
,
dtype
=
self
.
dtype
)
n
=
self
.
shared
(
data
)
t
=
n
[
idx
]
f
=
self
.
function
([],
t
.
shape
,
op
=
self
.
ops
,
N
=
(
1
,
0
)
)
f
=
self
.
function
([],
t
.
shape
,
op
=
self
.
ops
,
N
=
0
,
N_fast
=
1
)
val
=
f
()
self
.
assertTrue
(
numpy
.
allclose
(
val
,
data
[
idx
]
.
shape
))
...
...
@@ -2850,6 +2847,8 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
data_copy
[
idx
]
=
inc_num
else
:
data_copy
[
idx
]
+=
inc_num
data_var
=
theano
.
In
(
data_var
,
mutable
=
True
)
# Remember data for the Theano function (see below).
all_inputs_var
+=
[
data_var
,
idx_var
,
inc_var
]
all_inputs_num
+=
[
data_num
,
idx_num
,
inc_num
]
...
...
@@ -2869,9 +2868,16 @@ class T_subtensor(unittest.TestCase, utt.TestOptimizationMixin):
assert
(
data_num
==
data_num_init
)
.
all
()
# Actual test (we compile a single Theano function to make it faster).
f
=
self
.
function
(
all_inputs_var
,
all_outputs_var
,
accept_inplace
=
True
,
op
=
self
.
adv_incsub1
,
N
=
len
(
all_outputs_var
))
orig_warn
=
theano
.
config
.
warn
.
gpu_set_subtensor1
try
:
theano
.
config
.
warn
.
gpu_set_subtensor1
=
False
f
=
self
.
function
(
all_inputs_var
,
all_outputs_var
,
accept_inplace
=
True
,
op
=
self
.
adv_incsub1
,
N
=
len
(
all_outputs_var
))
finally
:
theano
.
config
.
warn
.
gpu_set_subtensor1
=
orig_warn
f_outs
=
f
(
*
all_inputs_num
)
assert
len
(
f_outs
)
==
len
(
all_outputs_num
)
for
f_out
,
output_num
in
izip
(
f_outs
,
all_outputs_num
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论