Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
af6361cd
提交
af6361cd
authored
11月 26, 2012
作者:
Ian Goodfellow
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
made test_blas use deterministic interface to theano.function
上级
8ebe4381
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
33 行增加
和
33 行删除
+33
-33
test_blas.py
theano/tensor/tests/test_blas.py
+33
-33
没有找到文件。
theano/tensor/tests/test_blas.py
浏览文件 @
af6361cd
...
@@ -185,8 +185,8 @@ class t_gemm(TestCase):
...
@@ -185,8 +185,8 @@ class t_gemm(TestCase):
l2_reg
=
T
.
constant
(
0.0001
)
.
astype
(
config
.
floatX
)
l2_reg
=
T
.
constant
(
0.0001
)
.
astype
(
config
.
floatX
)
#test constant merge with gemm
#test constant merge with gemm
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
T
.
dot
(
a
,
b
)
+
f
=
theano
.
function
([
a
,
b
],
updates
=
[(
s
,
lr1
*
T
.
dot
(
a
,
b
)
+
l2_reg
*
lr2
*
s
}
,
l2_reg
*
lr2
*
s
)]
,
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01,
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
...
@@ -195,8 +195,8 @@ class t_gemm(TestCase):
...
@@ -195,8 +195,8 @@ class t_gemm(TestCase):
assert
f
[
0
]
.
op
==
gemm_inplace
assert
f
[
0
]
.
op
==
gemm_inplace
#test factored scalar with merge
#test factored scalar with merge
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
lr1
*
(
T
.
dot
(
a
,
b
)
-
f
=
theano
.
function
([
a
,
b
],
updates
=
[(
s
,
lr1
*
(
T
.
dot
(
a
,
b
)
-
l2_reg
*
s
)
}
,
l2_reg
*
s
)
)]
,
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01,
#[Gemm{inplace}(<TensorType(float64, matrix)>, 0.01,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
...
@@ -206,7 +206,7 @@ class t_gemm(TestCase):
...
@@ -206,7 +206,7 @@ class t_gemm(TestCase):
#test factored scalar with merge and neg
#test factored scalar with merge and neg
f
=
theano
.
function
([
a
,
b
],
f
=
theano
.
function
([
a
,
b
],
updates
=
{
s
:
s
-
lr1
*
(
s
*
.
0002
+
T
.
dot
(
a
,
b
))}
,
updates
=
[(
s
,
s
-
lr1
*
(
s
*
.
0002
+
T
.
dot
(
a
,
b
)))]
,
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
mode
=
mode_not_fast_compile
)
.
maker
.
fgraph
.
toposort
()
#[Gemm{inplace}(<TensorType(float64, matrix)>, -0.01,
#[Gemm{inplace}(<TensorType(float64, matrix)>, -0.01,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
# <TensorType(float64, matrix)>, <TensorType(float64, matrix)>,
...
@@ -368,7 +368,7 @@ class t_gemm(TestCase):
...
@@ -368,7 +368,7 @@ class t_gemm(TestCase):
tz_i
=
gemm_no_inplace
(
tz
[:,
:,
i
],
ta
,
tx
[
tz_i
=
gemm_no_inplace
(
tz
[:,
:,
i
],
ta
,
tx
[
:,
:,
i
],
ty
[:,
:,
i
],
tb
)
:,
:,
i
],
ty
[:,
:,
i
],
tb
)
g_i
=
theano
.
function
([],
tz_i
,
g_i
=
theano
.
function
([],
tz_i
,
updates
=
{
tz
:
T
.
set_subtensor
(
tz
[:,
:,
i
],
tz_i
)}
,
updates
=
[(
tz
,
T
.
set_subtensor
(
tz
[:,
:,
i
],
tz_i
))]
,
mode
=
compile
.
Mode
(
optimizer
=
None
,
linker
=
l
))
mode
=
compile
.
Mode
(
optimizer
=
None
,
linker
=
l
))
for
j
in
xrange
(
3
):
for
j
in
xrange
(
3
):
g_i
()
g_i
()
...
@@ -801,7 +801,7 @@ def test_gemm_unrolled():
...
@@ -801,7 +801,7 @@ def test_gemm_unrolled():
cur_V
=
update_V
(
cur_H
)
cur_V
=
update_V
(
cur_H
)
cur_H
=
update_H
(
cur_V
)
cur_H
=
update_H
(
cur_V
)
unrolled_theano
=
theano
.
function
([],
updates
=
{
V
:
cur_V
,
H
:
cur_H
}
,
unrolled_theano
=
theano
.
function
([],
updates
=
[(
V
,
cur_V
),
(
H
,
cur_H
)]
,
name
=
'unrolled_theano'
)
name
=
'unrolled_theano'
)
nb_dot
=
sum
([
1
for
node
in
unrolled_theano
.
maker
.
fgraph
.
toposort
()
nb_dot
=
sum
([
1
for
node
in
unrolled_theano
.
maker
.
fgraph
.
toposort
()
if
isinstance
(
node
.
op
,
(
theano
.
tensor
.
Dot
,
if
isinstance
(
node
.
op
,
(
theano
.
tensor
.
Dot
,
...
@@ -1032,7 +1032,7 @@ def test_dot_w_self():
...
@@ -1032,7 +1032,7 @@ def test_dot_w_self():
p
=
T
.
dot
(
A
,
A
)
*
B
p
=
T
.
dot
(
A
,
A
)
*
B
grad
=
T
.
grad
(
T
.
mean
(
p
),
A
)
grad
=
T
.
grad
(
T
.
mean
(
p
),
A
)
f
=
theano
.
function
([
B
],
p
,
updates
=
{
A
:
A
-
grad
}
)
f
=
theano
.
function
([
B
],
p
,
updates
=
[(
A
,
A
-
grad
)]
)
# tests correctness in debugmode
# tests correctness in debugmode
f
(
numpy
.
asarray
([[
0
,
1
],
[
2
,
3
]],
dtype
=
config
.
floatX
))
f
(
numpy
.
asarray
([[
0
,
1
],
[
2
,
3
]],
dtype
=
config
.
floatX
))
...
@@ -1119,7 +1119,7 @@ class TestGemv(TestCase, unittest_tools.TestOptimizationMixin):
...
@@ -1119,7 +1119,7 @@ class TestGemv(TestCase, unittest_tools.TestOptimizationMixin):
assert
topo
[
0
]
.
op
.
inplace
==
False
assert
topo
[
0
]
.
op
.
inplace
==
False
#test the inplace version
#test the inplace version
g
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
m
,
v1
)}
,
g
=
theano
.
function
([],
[],
updates
=
[(
v2
,
v2
+
theano
.
dot
(
m
,
v1
))]
,
mode
=
mode_blas_opt
)
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
...
@@ -1169,7 +1169,7 @@ class TestGemv(TestCase, unittest_tools.TestOptimizationMixin):
...
@@ -1169,7 +1169,7 @@ class TestGemv(TestCase, unittest_tools.TestOptimizationMixin):
assert
topo
[
-
1
]
.
op
.
inplace
==
False
assert
topo
[
-
1
]
.
op
.
inplace
==
False
#test the inplace version
#test the inplace version
g
=
theano
.
function
([],
[],
updates
=
{
v2
:
v2
+
theano
.
dot
(
v1
,
m
)}
,
g
=
theano
.
function
([],
[],
updates
=
[(
v2
,
v2
+
theano
.
dot
(
v1
,
m
))]
,
mode
=
mode_blas_opt
)
mode
=
mode_blas_opt
)
# Assert they produce the same output
# Assert they produce the same output
...
@@ -1575,7 +1575,7 @@ class TestGer(TestCase, unittest_tools.TestOptimizationMixin):
...
@@ -1575,7 +1575,7 @@ class TestGer(TestCase, unittest_tools.TestOptimizationMixin):
def
function
(
self
,
inputs
,
outputs
,
updates
=
None
):
def
function
(
self
,
inputs
,
outputs
,
updates
=
None
):
if
updates
is
None
:
if
updates
is
None
:
updates
=
{}
updates
=
[]
return
theano
.
function
(
inputs
,
outputs
,
self
.
mode
,
updates
=
updates
)
return
theano
.
function
(
inputs
,
outputs
,
self
.
mode
,
updates
=
updates
)
def
b
(
self
,
bval
):
def
b
(
self
,
bval
):
...
@@ -1691,8 +1691,8 @@ class TestGer(TestCase, unittest_tools.TestOptimizationMixin):
...
@@ -1691,8 +1691,8 @@ class TestGer(TestCase, unittest_tools.TestOptimizationMixin):
def
test_inplace
(
self
):
def
test_inplace
(
self
):
A
=
self
.
shared
(
numpy
.
random
.
rand
(
4
,
5
)
.
astype
(
self
.
dtype
))
A
=
self
.
shared
(
numpy
.
random
.
rand
(
4
,
5
)
.
astype
(
self
.
dtype
))
f
=
self
.
function
([
self
.
x
,
self
.
y
],
[],
f
=
self
.
function
([
self
.
x
,
self
.
y
],
[],
updates
=
{
A
:
A
+
T
.
constant
(
0.1
,
dtype
=
self
.
dtype
)
*
updates
=
[(
A
,
A
+
T
.
constant
(
0.1
,
dtype
=
self
.
dtype
)
*
T
.
outer
(
self
.
x
,
self
.
y
)
}
)
T
.
outer
(
self
.
x
,
self
.
y
)
)]
)
self
.
assertFunctionContains
(
f
,
self
.
ger_destructive
)
self
.
assertFunctionContains
(
f
,
self
.
ger_destructive
)
f
(
numpy
.
random
.
rand
(
4
)
.
astype
(
self
.
dtype
),
f
(
numpy
.
random
.
rand
(
4
)
.
astype
(
self
.
dtype
),
numpy
.
random
.
rand
(
5
)
.
astype
(
self
.
dtype
))
numpy
.
random
.
rand
(
5
)
.
astype
(
self
.
dtype
))
...
@@ -1731,15 +1731,15 @@ class TestBlasStrides(TestCase):
...
@@ -1731,15 +1731,15 @@ class TestBlasStrides(TestCase):
bt_dev
=
b_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
bt_dev
=
b_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
f_nn
=
theano
.
function
([],
[],
updates
=
{
a
:
tensor
.
dot
(
b
,
c
)}
,
f_nn
=
theano
.
function
([],
[],
updates
=
[(
a
,
tensor
.
dot
(
b
,
c
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
#print 'class name:', self.__class__.__name__
#print 'class name:', self.__class__.__name__
#theano.printing.debugprint(f_nn)
#theano.printing.debugprint(f_nn)
f_nt
=
theano
.
function
([],
[],
updates
=
{
a
:
tensor
.
dot
(
b
,
c_t
.
T
)}
,
f_nt
=
theano
.
function
([],
[],
updates
=
[(
a
,
tensor
.
dot
(
b
,
c_t
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tn
=
theano
.
function
([],
[],
updates
=
{
a
:
tensor
.
dot
(
b_t
.
T
,
c
)}
,
f_tn
=
theano
.
function
([],
[],
updates
=
[(
a
,
tensor
.
dot
(
b_t
.
T
,
c
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tt
=
theano
.
function
([],
[],
updates
=
{
a
:
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
)}
,
f_tt
=
theano
.
function
([],
[],
updates
=
[(
a
,
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
# Try with all stride patterns, and all transposed pattern
# Try with all stride patterns, and all transposed pattern
...
@@ -1802,14 +1802,14 @@ class TestBlasStrides(TestCase):
...
@@ -1802,14 +1802,14 @@ class TestBlasStrides(TestCase):
bt_dev
=
b_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
bt_dev
=
b_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
f_nn
=
theano
.
function
([],
[],
updates
=
{
a
:
l
*
tensor
.
dot
(
b
,
c
)}
,
f_nn
=
theano
.
function
([],
[],
updates
=
[(
a
,
l
*
tensor
.
dot
(
b
,
c
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_nt
=
theano
.
function
([],
[],
updates
=
{
a
:
l
*
tensor
.
dot
(
b
,
c_t
.
T
)}
,
f_nt
=
theano
.
function
([],
[],
updates
=
[(
a
,
l
*
tensor
.
dot
(
b
,
c_t
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tn
=
theano
.
function
([],
[],
updates
=
{
a
:
l
*
tensor
.
dot
(
b_t
.
T
,
c
)}
,
f_tn
=
theano
.
function
([],
[],
updates
=
[(
a
,
l
*
tensor
.
dot
(
b_t
.
T
,
c
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tt
=
theano
.
function
([],
[],
f_tt
=
theano
.
function
([],
[],
updates
=
{
a
:
l
*
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
)}
,
updates
=
[(
a
,
l
*
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
# Try with all stride patterns, and all transposed pattern
# Try with all stride patterns, and all transposed pattern
...
@@ -1875,28 +1875,28 @@ class TestBlasStrides(TestCase):
...
@@ -1875,28 +1875,28 @@ class TestBlasStrides(TestCase):
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
ct_dev
=
c_t
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
f_nnn
=
theano
.
function
([],
[],
f_nnn
=
theano
.
function
([],
[],
updates
=
{
a
:
(
l
*
a
+
tensor
.
dot
(
b
,
c
))}
,
updates
=
[(
a
,
(
l
*
a
+
tensor
.
dot
(
b
,
c
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_nnt
=
theano
.
function
([],
[],
f_nnt
=
theano
.
function
([],
[],
updates
=
{
a
:
(
l
*
a
+
tensor
.
dot
(
b
,
c_t
.
T
))}
,
updates
=
[(
a
,
(
l
*
a
+
tensor
.
dot
(
b
,
c_t
.
T
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_ntn
=
theano
.
function
([],
[],
f_ntn
=
theano
.
function
([],
[],
updates
=
{
a
:
(
l
*
a
+
tensor
.
dot
(
b_t
.
T
,
c
))}
,
updates
=
[(
a
,
(
l
*
a
+
tensor
.
dot
(
b_t
.
T
,
c
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_ntt
=
theano
.
function
([],
[],
f_ntt
=
theano
.
function
([],
[],
updates
=
{
a
:
(
l
*
a
+
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
))}
,
updates
=
[(
a
,
(
l
*
a
+
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tnn
=
theano
.
function
([],
[],
f_tnn
=
theano
.
function
([],
[],
updates
=
{
a_t
:
(
l
*
a_t
+
tensor
.
dot
(
b
,
c
)
.
T
)}
,
updates
=
[(
a_t
,
(
l
*
a_t
+
tensor
.
dot
(
b
,
c
)
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_tnt
=
theano
.
function
([],
[],
f_tnt
=
theano
.
function
([],
[],
updates
=
{
a_t
:
(
l
*
a_t
+
tensor
.
dot
(
b
,
c_t
.
T
)
.
T
)}
,
updates
=
[(
a_t
,
(
l
*
a_t
+
tensor
.
dot
(
b
,
c_t
.
T
)
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_ttn
=
theano
.
function
([],
[],
f_ttn
=
theano
.
function
([],
[],
updates
=
{
a_t
:
(
l
*
a_t
+
tensor
.
dot
(
b_t
.
T
,
c
)
.
T
)}
,
updates
=
[(
a_t
,
(
l
*
a_t
+
tensor
.
dot
(
b_t
.
T
,
c
)
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_ttt
=
theano
.
function
([],
[],
f_ttt
=
theano
.
function
([],
[],
updates
=
{
a_t
:
(
l
*
a_t
+
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
)
.
T
)}
,
updates
=
[(
a_t
,
(
l
*
a_t
+
tensor
.
dot
(
b_t
.
T
,
c_t
.
T
)
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
# Try with all stride patterns, and all transposed pattern
# Try with all stride patterns, and all transposed pattern
...
@@ -1985,11 +1985,11 @@ class TestBlasStrides(TestCase):
...
@@ -1985,11 +1985,11 @@ class TestBlasStrides(TestCase):
b_dev
=
b
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
b_dev
=
b
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
c_dev
=
c
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
c_dev
=
c
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
f_n
=
theano
.
function
([],
[],
updates
=
{
a
:
(
a
+
l
*
tensor
.
dot
(
b
,
c
))}
,
f_n
=
theano
.
function
([],
[],
updates
=
[(
a
,
(
a
+
l
*
tensor
.
dot
(
b
,
c
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_t
=
theano
.
function
([],
[],
f_t
=
theano
.
function
([],
[],
updates
=
{
a
:
(
a
+
l
*
tensor
.
dot
(
b_t
.
T
,
c
))}
,
updates
=
[(
a
,
(
a
+
l
*
tensor
.
dot
(
b_t
.
T
,
c
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
# Try with all stride patterns, and all transposed pattern
# Try with all stride patterns, and all transposed pattern
...
@@ -2041,11 +2041,11 @@ class TestBlasStrides(TestCase):
...
@@ -2041,11 +2041,11 @@ class TestBlasStrides(TestCase):
c_dev
=
c
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
c_dev
=
c
.
get_value
(
borrow
=
False
,
return_internal_type
=
True
)
f_n
=
theano
.
function
([],
[],
f_n
=
theano
.
function
([],
[],
updates
=
{
a
:
(
a
+
l
*
tensor
.
outer
(
b
,
c
))}
,
updates
=
[(
a
,
(
a
+
l
*
tensor
.
outer
(
b
,
c
)))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
f_t
=
theano
.
function
([],
[],
f_t
=
theano
.
function
([],
[],
updates
=
{
a_t
:
(
a_t
+
l
*
tensor
.
outer
(
b
,
c
)
.
T
)}
,
updates
=
[(
a_t
,
(
a_t
+
l
*
tensor
.
outer
(
b
,
c
)
.
T
))]
,
mode
=
self
.
mode
)
mode
=
self
.
mode
)
# Try with all stride patterns, and all transposed patterns
# Try with all stride patterns, and all transposed patterns
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论