Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
0b5dbed9
提交
0b5dbed9
authored
2月 25, 2016
作者:
Olivier Mastropietro
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed the PEP8 Error. Modified some tests to meet the standards without changing the output
上级
0aa5ff77
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
139 行增加
和
120 行删除
+139
-120
test_builders.py
theano/compile/tests/test_builders.py
+19
-20
test_debugmode.py
theano/compile/tests/test_debugmode.py
+9
-9
test_function_module.py
theano/compile/tests/test_function_module.py
+96
-78
test_misc.py
theano/compile/tests/test_misc.py
+6
-3
test_monitormode.py
theano/compile/tests/test_monitormode.py
+1
-1
test_pfunc.py
theano/compile/tests/test_pfunc.py
+4
-4
test_profiling.py
theano/compile/tests/test_profiling.py
+3
-3
test_shared.py
theano/compile/tests/test_shared.py
+1
-2
没有找到文件。
theano/compile/tests/test_builders.py
浏览文件 @
0b5dbed9
...
...
@@ -4,7 +4,6 @@ from theano import config, shared
from
theano.compile
import
function
from
theano
import
tensor
from
theano
import
tensor
as
T
from
theano.tensor.shared_randomstreams
import
RandomStreams
...
...
@@ -24,8 +23,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
# print function, function.__module__
# print fn.maker.fgraph.toposort()
fn
(
xv
,
yv
,
zv
)
...
...
@@ -39,8 +38,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
op
(
x
,
op
(
y
,
z
))
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
3
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
3
,
4
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
4
,
5
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
3
,
4
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
4
,
5
),
dtype
=
config
.
floatX
)
*
5
res
=
fn
(
xv
,
yv
,
zv
)
assert
res
.
shape
==
(
2
,
5
)
assert
numpy
.
all
(
180.0
==
res
)
...
...
@@ -56,8 +55,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
f
-
T
.
grad
(
T
.
sum
(
f
),
y
)
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
assert
numpy
.
all
(
11.0
==
fn
(
xv
,
yv
,
zv
))
def
test_grad_grad
(
self
):
...
...
@@ -69,8 +68,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
f
=
f
-
T
.
grad
(
T
.
sum
(
f
),
y
)
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
assert
numpy
.
allclose
(
6.0
,
fn
(
xv
,
yv
,
zv
))
def
test_shared
(
self
):
...
...
@@ -83,8 +82,8 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
# print function, function.__module__
# print fn.maker.fgraph.toposort()
assert
numpy
.
allclose
(
8.0
,
fn
(
xv
,
yv
,
zv
))
...
...
@@ -116,7 +115,7 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
out1
=
x
*
y
out2
=
y
*
z
op1
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
])
op1
=
OpFromGraph
([
x
,
y
,
z
],
[
out1
,
out2
])
results
=
op1
.
connection_pattern
(
None
)
expect_result
=
[[
True
,
False
],
[
True
,
True
],
...
...
@@ -139,7 +138,7 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
# Inner graph where some computation doesn't rely on explicit inputs
srng
=
RandomStreams
(
seed
=
234
)
rv_u
=
srng
.
uniform
((
2
,
2
))
rv_u
=
srng
.
uniform
((
2
,
2
))
x
,
y
=
T
.
matrices
(
'xy'
)
out1
=
x
+
rv_u
out2
=
y
+
3
...
...
@@ -155,14 +154,14 @@ class T_OpFromGraph(unittest_tools.InferShapeTester):
def
test_infer_shape
(
self
):
x
=
T
.
matrix
(
'x'
)
y
=
T
.
matrix
(
'y'
)
o1
=
x
+
y
o2
=
x
*
y
op_graph
=
OpFromGraph
([
x
,
y
],
[
o1
,
o2
])
o1
=
x
+
y
o2
=
x
*
y
op_graph
=
OpFromGraph
([
x
,
y
],
[
o1
,
o2
])
q
=
T
.
matrix
(
'q'
)
p
=
T
.
matrix
(
'p'
)
self
.
_compile_and_check
([
q
,
p
],
op_graph
(
q
,
p
),
[
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
),
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
)],
self
.
_compile_and_check
([
q
,
p
],
op_graph
(
q
,
p
),
[
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
),
numpy
.
ones
([
3
,
4
],
dtype
=
config
.
floatX
)],
OpFromGraph
)
theano/compile/tests/test_debugmode.py
浏览文件 @
0b5dbed9
...
...
@@ -160,16 +160,16 @@ class WeirdBrokenOp(gof.Op):
if
self
.
behaviour
==
'times2'
:
behaviour
=
" Dz[m * Sz] = 2 * Da[m * Sa]; "
#out[0] = a * 2
#
out[0] = a * 2
elif
self
.
behaviour
==
'times2_inplace'
:
#out[0] = a
#out[0] *= 2
#
out[0] = a
#
out[0] *= 2
behaviour
=
" Dz[m * Sz] = 2 * Da[m * Sa]; "
elif
self
.
behaviour
==
'times1'
:
#out[0] = a * 1
#
out[0] = a * 1
behaviour
=
" Dz[m * Sz] = Da[m * Sa]; "
elif
self
.
behaviour
==
'times1_inplace'
:
#out[0] = a
#
out[0] = a
behaviour
=
""
else
:
raise
ValueError
(
self
.
behaviour
)
...
...
@@ -189,7 +189,7 @@ wb1 = WeirdBrokenOp('times1')
def
test_badthunkoutput
():
# Check if the c and python code is consistent.
# Check if the c and python code is consistent.
a
=
theano
.
tensor
.
dvector
()
b
=
theano
.
tensor
.
dvector
()
...
...
@@ -533,7 +533,7 @@ class Test_ViewMap(unittest.TestCase):
# pretending that it is aliased to both the outputs.
# This unfairly disables any destructive operations on the
# input, but guarantees correctness.
#custom_op.view_map = {0:[0], 1:[1]}
#
custom_op.view_map = {0:[0], 1:[1]}
# f([1,2,3,4],[5,6,7,8])
...
...
@@ -737,7 +737,7 @@ class Test_preallocated_output(unittest.TestCase):
check_preallocated_output
=
[
'c_contiguous'
])
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
mode
)
out_val
=
f
(
a_val
,
b_val
)
#
out_val = f(a_val, b_val)
# print 'out_val =', out_val
# print out_val.strides
...
...
@@ -769,7 +769,7 @@ class Test_preallocated_output(unittest.TestCase):
check_preallocated_output
=
[
'c_contiguous'
])
f
=
theano
.
function
([
a
,
b
],
out
,
mode
=
mode
)
out_val
=
f
(
a_val
,
b_val
)
#
out_val = f(a_val, b_val)
# print 'out_val =', out_val
# print out_val.strides
...
...
theano/compile/tests/test_function_module.py
浏览文件 @
0b5dbed9
...
...
@@ -19,7 +19,10 @@ import theano
import
numpy
as
N
PatternOptimizer
=
lambda
p1
,
p2
,
ign
=
True
:
gof
.
OpKeyOptimizer
(
gof
.
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
# PatternOptimizer = lambda p1, p2, ign=True: gof.OpKeyOptimizer(gof.PatternSub(p1, p2), ignore_newtrees=ign)
def
PatternOptimizer
(
p1
,
p2
,
ign
=
True
):
return
gof
.
OpKeyOptimizer
(
gof
.
PatternSub
(
p1
,
p2
),
ignore_newtrees
=
ign
)
def
checkfor
(
testcase
,
fn
,
E
):
...
...
@@ -60,79 +63,88 @@ class T_function(unittest.TestCase):
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([],
[
x
])
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
[
x
],
on_unused_input
=
'ignore'
)
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
[
x
])
return
fn
checkfor
(
self
,
fn
,
UnusedInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
x
,
on_unused_input
=
'ignore'
)
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
x
)
return
fn
checkfor
(
self
,
fn
,
UnusedInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
# Ignore unused input s, as it hides the other error
fn
=
function
([
s
],
Out
(
x
),
on_unused_input
=
'ignore'
)
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
],
Out
(
x
))
return
fn
checkfor
(
self
,
fn
,
UnusedInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
In
(
x
,
update
=
s
+
x
)],
x
)
fn
=
function
([
In
(
x
,
update
=
s
+
x
)],
x
)
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
fn
():
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
In
(
x
,
update
=
((
s
*
s
)
+
x
))],
x
)
return
fn
checkfor
(
self
,
fn
,
MissingInputError
)
def
test_input_anon_singleton
(
self
):
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
,
x
],
[
x
+
s
])
fn
=
function
([
s
,
x
],
[
x
+
s
])
self
.
assertTrue
(
fn
(
2
,
3
)
==
[
5
])
# no state
self
.
assertTrue
(
fn
(
2
,
3
)
==
[
5
])
def
test_input_anon_unpack
(
self
):
x
,
s
=
T
.
scalars
(
'xs'
)
fn
=
function
([
s
,
x
],
x
+
s
)
fn
=
function
([
s
,
x
],
x
+
s
)
self
.
assertTrue
(
fn
(
2
,
3
)
==
5
)
def
test_naming_rule0
(
self
):
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
s
],
x
/
s
)
f
=
function
([
x
,
s
],
x
/
s
)
self
.
assertTrue
(
f
(
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
s
=
2
,
x
=
1
)
==
0.5
)
self
.
assertTrue
(
f
(
x
=
2
,
s
=
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
checkfor
(
self
,
lambda
:
f
(
2
,
x
=
2.0
),
TypeError
)
# got multiple values for keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
x
=
1
),
TypeError
)
# takes exactly 2 non-keyword arguments (1 given)
checkfor
(
self
,
lambda
:
f
(
s
=
1
),
TypeError
)
# takes exactly 2 non-keyword arguments (0 given)
checkfor
(
self
,
lambda
:
f
(
2
,
x
=
2.0
),
TypeError
)
# got multiple values for keyword argument 'x'
checkfor
(
self
,
lambda
:
f
(
x
=
1
),
TypeError
)
# takes exactly 2 non-keyword arguments (1 given)
checkfor
(
self
,
lambda
:
f
(
s
=
1
),
TypeError
)
# takes exactly 2 non-keyword arguments (0 given)
def
test_naming_rule1
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
a
,
s
],
a
/
s
)
f
=
function
([
a
,
s
],
a
/
s
)
self
.
assertTrue
(
f
(
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
2
,
s
=
1
)
==
2.0
)
...
...
@@ -145,7 +157,7 @@ class T_function(unittest.TestCase):
# x's name is ignored because it is followed by anonymous parameter a.
# Ignore unused input x, as it hides the other error
f
=
function
([
x
,
a
,
s
],
a
/
s
,
on_unused_input
=
'ignore'
)
f
=
function
([
x
,
a
,
s
],
a
/
s
,
on_unused_input
=
'ignore'
)
self
.
assertTrue
(
f
(
9
,
1
,
2
)
==
0.5
)
self
.
assertTrue
(
f
(
9
,
2
,
1
)
==
2.0
)
self
.
assertTrue
(
f
(
9
,
2
,
s
=
1
)
==
2.0
)
...
...
@@ -157,7 +169,7 @@ class T_function(unittest.TestCase):
x
,
s
=
T
.
scalars
(
'xs'
)
# x's name is not ignored (as in test_naming_rule2) because a has a default value.
f
=
function
([
x
,
In
(
a
,
value
=
1.0
),
s
],
a
/
s
+
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
),
s
],
a
/
s
+
x
)
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
# can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
self
.
assertTrue
(
f
(
9
,
s
=
4
)
==
9.25
)
# can give s as kwarg, get default a
...
...
@@ -170,7 +182,7 @@ class T_function(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
s
],
a
/
s
+
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
s
],
a
/
s
+
x
)
self
.
assertTrue
(
f
(
9
,
2
,
4
)
==
9.5
)
# can specify all args in order
self
.
assertTrue
(
f
(
9
,
2
,
s
=
4
)
==
9.5
)
# can give s as kwarg
...
...
@@ -185,7 +197,7 @@ class T_function(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
)],
s
+
a
*
x
)
self
.
assertTrue
(
f
[
a
]
==
1.0
)
self
.
assertTrue
(
f
[
s
]
==
0.0
)
...
...
@@ -204,7 +216,7 @@ class T_function(unittest.TestCase):
def
test_same_names
(
self
):
a
,
x
,
s
=
T
.
scalars
(
'xxx'
)
# implicit names would cause error. What do we do?
f
=
function
([
a
,
x
,
s
],
a
+
x
+
s
)
f
=
function
([
a
,
x
,
s
],
a
+
x
+
s
)
self
.
assertTrue
(
f
(
1
,
2
,
3
)
==
6
)
checkfor
(
self
,
lambda
:
f
(
1
,
2
,
x
=
3
),
TypeError
)
...
...
@@ -216,14 +228,15 @@ class T_function(unittest.TestCase):
def
t
():
f
=
function
([
In
(
a
,
name
=
set
([
'adsf'
,
()]),
value
=
1.0
),
In
(
x
,
name
=
(),
value
=
2.0
),
In
(
s
,
name
=
T
.
scalar
(),
value
=
3.0
)],
a
+
x
+
s
)
In
(
s
,
name
=
T
.
scalar
(),
value
=
3.0
)],
a
+
x
+
s
)
return
f
checkfor
(
self
,
t
,
TypeError
)
def
test_copy
(
self
):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
g
=
copy
.
copy
(
f
)
# if they both return, assume that they return equivalent things.
...
...
@@ -246,17 +259,17 @@ class T_function(unittest.TestCase):
# SharedVariable for tests, one of them has update
y
=
theano
.
shared
(
value
=
1
)
z
=
theano
.
shared
(
value
=
2
)
out
=
T
.
tanh
((
x
+
y
+
2
)
/
(
x
+
z
-
0.2
)
**
2
)
out
=
T
.
tanh
((
x
+
y
+
2
)
/
(
x
+
z
-
0.2
)
**
2
)
# Test for different linkers
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
ori
=
theano
.
function
([
x
],
[
out
],
mode
=
mode
,
updates
=
{
z
:
z
+
1
})
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
ori
=
theano
.
function
([
x
],
[
out
],
mode
=
mode
,
updates
=
{
z
:
z
+
1
})
cpy
=
ori
.
copy
(
share_memory
=
True
)
# Test if memories shared
storage_map_ori
=
ori
.
fn
.
storage_map
storage_map_cpy
=
cpy
.
fn
.
storage_map
fgraph_ori
=
ori
.
maker
.
fgraph
#
fgraph_ori = ori.maker.fgraph
fgraph_cpy
=
cpy
.
maker
.
fgraph
# Assert intermediate and Constants storages are shared.
...
...
@@ -266,7 +279,7 @@ class T_function(unittest.TestCase):
for
key
in
storage_map_cpy
.
keys
():
storage
=
storage_map_cpy
[
key
]
if
key
not
in
i_o_variables
or
isinstance
(
key
,
theano
.
tensor
.
Constant
):
self
.
assertTrue
(
any
([
storage
is
s
for
s
in
ori_storages
]))
self
.
assertTrue
(
any
([
storage
is
s
for
s
in
ori_storages
]))
# Assert storages of SharedVariable without updates are shared
for
(
input
,
_1
,
_2
),
here
,
there
in
zip
(
ori
.
indices
,
...
...
@@ -285,24 +298,24 @@ class T_function(unittest.TestCase):
m
=
theano
.
shared
(
value
=
0
,
name
=
'm'
)
# SharedVariable to replace
y_rpl
=
theano
.
shared
(
value
=
3
,
name
=
'y_rpl'
)
y_rpl
=
theano
.
shared
(
value
=
3
,
name
=
'y_rpl'
)
z_rpl
=
theano
.
shared
(
value
=
4
,
name
=
'z_rpl'
)
swap
=
{
y
:
y_rpl
,
z
:
z_rpl
}
map_SV
=
{
'y_rpl'
:
y_rpl
,
'z_rpl'
:
z_rpl
}
swap
=
{
y
:
y_rpl
,
z
:
z_rpl
}
map_SV
=
{
'y_rpl'
:
y_rpl
,
'z_rpl'
:
z_rpl
}
out
=
x
+
y
+
z
+
m
out
=
x
+
y
+
z
+
m
# Test for different linkers
# for mode in ["FAST_RUN","FAST_COMPILE"]:
second_time
=
False
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
ori
=
theano
.
function
([
i
],
[
out
],
mode
=
mode
,
updates
=
[(
z
,
z
+
1
),(
m
,
m
+
2
)],
givens
=
{
x
:
x_list
[
i
]})
updates
=
[(
z
,
z
+
1
),
(
m
,
m
+
2
)],
givens
=
{
x
:
x_list
[
i
]})
cpy
=
ori
.
copy
(
swap
=
swap
)
# run fuction several time
ori
(
1
),
cpy
(
1
),
cpy
(
2
)
ori
(
1
),
cpy
(
1
),
cpy
(
2
)
# assert same SharedVariable are update in different function
if
not
second_time
:
...
...
@@ -333,31 +346,33 @@ class T_function(unittest.TestCase):
second_time
=
True
def
test_swap_SharedVar
ai
le_with_given
(
self
):
def
test_swap_SharedVar
iab
le_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
"""
train_x
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
test_x
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
train_x
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
test_x
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
10
)
.
astype
(
config
.
floatX
))
train_y
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
1
)
.
astype
(
config
.
floatX
))
test_y
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
1
)
.
astype
(
config
.
floatX
))
train_y
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
1
)
.
astype
(
config
.
floatX
))
test_y
=
theano
.
shared
(
value
=
numpy
.
random
.
rand
(
10
,
1
)
.
astype
(
config
.
floatX
))
i
=
T
.
iscalar
(
'index'
)
x
=
T
.
vector
(
'x'
)
y
=
T
.
vector
(
'y'
)
# this formular has no sense but for a test
out
=
(
T
.
sum
(
x
)
-
y
)
**
2
out2
=
(
T
.
sum
(
x
)
+
y
)
**
2
train
=
theano
.
function
([
i
],
out
,
givens
=
{
x
:
train_x
[
i
],
y
:
train_y
[
i
]},
updates
=
{
train_x
:
train_x
+
0.1
})
givens
=
{
x
:
train_x
[
i
],
y
:
train_y
[
i
]},
updates
=
{
train_x
:
train_x
+
0.1
})
test_def
=
theano
.
function
([
i
],
out
,
givens
=
{
x
:
test_x
[
i
],
y
:
test_y
[
i
]})
test_cpy
=
train
.
copy
(
swap
=
{
train_x
:
test_x
,
train_y
:
test_y
},
delete_updates
=
True
)
test_def
=
theano
.
function
([
i
],
out
,
givens
=
{
x
:
test_x
[
i
],
y
:
test_y
[
i
]})
test_def2
=
theano
.
function
([
i
],
out2
,
givens
=
{
x
:
test_x
[
i
],
y
:
test_y
[
i
]})
# test_cpy = train.copy(swap={train_x: test_x, train_y: test_y},
# delete_updates=True)
for
in1
,
in2
in
zip
(
test_def
.
maker
.
inputs
,
test_def
.
maker
.
inputs
):
for
in1
,
in2
in
zip
(
test_def
.
maker
.
inputs
,
test_def2
.
maker
.
inputs
):
assert
in1
.
value
is
in2
.
value
def
test_copy_delete_updates
(
self
):
...
...
@@ -365,13 +380,13 @@ class T_function(unittest.TestCase):
# SharedVariable for tests, one of them has update
y
=
theano
.
shared
(
value
=
1
,
name
=
'y'
)
z
=
theano
.
shared
(
value
=
2
,
name
=
'z'
)
out
=
x
+
y
+
z
out
=
x
+
y
+
z
# Test for different linkers
# for mode in ["FAST_RUN","FAST_COMPILE"]:
second_time
=
False
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
ori
=
theano
.
function
([
x
],
out
,
mode
=
mode
,
updates
=
{
z
:
z
*
2
})
#
second_time = False
for
mode
in
[
"FAST_RUN"
,
"FAST_COMPILE"
]:
ori
=
theano
.
function
([
x
],
out
,
mode
=
mode
,
updates
=
{
z
:
z
*
2
})
cpy
=
ori
.
copy
(
delete_updates
=
True
)
assert
cpy
(
1
)[
0
]
==
4
...
...
@@ -382,8 +397,8 @@ class T_function(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
],
update
=
s
-
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
],
update
=
s
-
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
(
1
,
2
)
self
.
assertTrue
(
f
[
s
]
==
2
)
...
...
@@ -396,8 +411,8 @@ class T_function(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
])],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
])],
s
+
a
*
x
)
f
(
1
,
2
)
self
.
assertTrue
(
f
[
s
]
==
2
)
...
...
@@ -411,9 +426,9 @@ class T_function(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
False
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
])],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
False
)],
s
+
a
*
x
)
g
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f
.
container
[
s
])],
s
+
a
*
x
)
f
(
1
,
2
)
self
.
assertTrue
(
f
[
s
]
==
2
)
...
...
@@ -431,8 +446,8 @@ class T_function(unittest.TestCase):
# behavior is still intended the doc and the test should both be
# updated accordingly.
x
,
s
=
T
.
scalars
(
'xs'
)
inc
=
function
([
x
,
In
(
s
,
update
=
(
s
+
x
),
value
=
10.0
)],
[])
dec
=
function
([
x
,
In
(
s
,
update
=
(
s
-
x
),
value
=
inc
.
container
[
s
],
inc
=
function
([
x
,
In
(
s
,
update
=
(
s
+
x
),
value
=
10.0
)],
[])
dec
=
function
([
x
,
In
(
s
,
update
=
(
s
-
x
),
value
=
inc
.
container
[
s
],
implicit
=
False
)],
[])
self
.
assertTrue
(
dec
[
s
]
is
inc
[
s
])
inc
[
s
]
=
2
...
...
@@ -482,8 +497,8 @@ class T_function(unittest.TestCase):
aval
=
numpy
.
random
.
rand
(
3
,
3
)
# when borrow=False, test that a destroy map cannot alias output to input
f
=
theano
.
function
([
In
(
a
,
borrow
=
False
)],
Out
(
a
+
1
,
borrow
=
True
))
assert
numpy
.
all
(
f
(
aval
)
==
aval
+
1
)
f
=
theano
.
function
([
In
(
a
,
borrow
=
False
)],
Out
(
a
+
1
,
borrow
=
True
))
assert
numpy
.
all
(
f
(
aval
)
==
aval
+
1
)
assert
not
numpy
.
may_share_memory
(
aval
,
f
(
aval
))
# when borrow=False, test that a viewmap cannot alias output to input
...
...
@@ -497,18 +512,18 @@ class T_function(unittest.TestCase):
o
=
N
.
ones
((
3
,
3
))
assert
o
is
not
f
(
o
)
# function no longer permits aliasing outputs to inputs
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
False
))
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
False
))
o
=
N
.
ones
((
3
,
3
))
four
=
f
(
o
)
assert
numpy
.
all
(
four
==
4
)
f
(
o
+
.
1
)
# should not clobber the memory used to store four
f
(
o
+
.
1
)
# should not clobber the memory used to store four
assert
numpy
.
all
(
four
==
4
)
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
True
),
mode
=
theano
.
Mode
(
'c|py_nogc'
,
'fast_run'
))
f
=
function
([
a
],
Out
(
a
*
4
,
borrow
=
True
),
mode
=
theano
.
Mode
(
'c|py_nogc'
,
'fast_run'
))
o
=
N
.
ones
((
3
,
3
))
four
=
f
(
o
)
assert
numpy
.
all
(
four
==
4
)
f
(
o
+
.
1
)
# should clobber the memory used to store four
f
(
o
+
.
1
)
# should clobber the memory used to store four
if
theano
.
config
.
cxx
:
assert
not
numpy
.
all
(
four
==
4
)
else
:
...
...
@@ -519,15 +534,15 @@ class T_function(unittest.TestCase):
def
test_disconnected_input
(
self
):
a
=
T
.
scalar
(
'a'
)
v
=
T
.
vector
(
'v'
)
self
.
assertRaises
(
UnusedInputError
,
function
,
[
a
,
v
],
v
*
2
)
f
=
function
([
a
,
v
],
v
*
2
,
on_unused_input
=
'ignore'
)
self
.
assertRaises
(
UnusedInputError
,
function
,
[
a
,
v
],
v
*
2
)
f
unction
([
a
,
v
],
v
*
2
,
on_unused_input
=
'ignore'
)
def
test_masked_input
(
self
):
m
=
T
.
matrix
(
'm'
)
mt
=
m
.
T
mt
.
name
=
'm.T'
self
.
assertRaises
(
UnusedInputError
,
function
,
[
m
,
mt
],
mt
*
2
)
f
=
function
([
m
,
mt
],
mt
*
2
,
on_unused_input
=
'ignore'
)
self
.
assertRaises
(
UnusedInputError
,
function
,
[
m
,
mt
],
mt
*
2
)
f
unction
([
m
,
mt
],
mt
*
2
,
on_unused_input
=
'ignore'
)
def
test_givens_input_var
(
self
):
"""
...
...
@@ -542,7 +557,7 @@ class T_function(unittest.TestCase):
Make test on free() function
"""
x
=
T
.
vector
(
'x'
)
func
=
function
([
x
],
x
+
1
)
func
=
function
([
x
],
x
+
1
)
func
.
fn
.
allow_gc
=
False
func
([
1
])
...
...
@@ -565,7 +580,7 @@ class T_picklefunction(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
try
:
g
=
copy
.
deepcopy
(
f
)
...
...
@@ -630,7 +645,7 @@ class T_picklefunction(unittest.TestCase):
a
=
T
.
scalar
()
# the a is for 'anonymous' (un-named).
x
,
s
=
T
.
scalars
(
'xs'
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
try
:
# Note that here we also test protocol 0 on purpose, since it
...
...
@@ -668,7 +683,7 @@ class T_picklefunction(unittest.TestCase):
xm
=
T
.
dmatrix
(
'x'
)
sm
=
T
.
dmatrix
(
's'
)
f
=
function
([
a
,
x
,
s
,
xm
,
sm
],
((
a
.
T
.
T
)
*
(
tensor
.
dot
(
xm
,
(
sm
.
T
.
T
.
T
))
+
x
)
.
T
*
(
x
/
x
)
+
s
))
f
=
function
([
a
,
x
,
s
,
xm
,
sm
],
((
a
.
T
.
T
)
*
(
tensor
.
dot
(
xm
,
(
sm
.
T
.
T
.
T
))
+
x
)
.
T
*
(
x
/
x
)
+
s
))
old_default_mode
=
config
.
mode
old_default_opt
=
config
.
optimizer
old_default_link
=
config
.
linker
...
...
@@ -713,13 +728,13 @@ class T_picklefunction(unittest.TestCase):
list_of_things
=
[
s
,
x
,
v
]
# some derived thing, whose inputs aren't all in the list
list_of_things
.
append
(
a
*
x
+
s
)
list_of_things
.
append
(
a
*
x
+
s
)
f1
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f1
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
list_of_things
.
append
(
f1
)
# now put in a function sharing container with the previous one
f2
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f1
.
container
[
s
],
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
f2
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
f1
.
container
[
s
],
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
list_of_things
.
append
(
f2
)
assert
isinstance
(
f2
.
container
[
s
]
.
storage
,
list
)
...
...
@@ -727,7 +742,7 @@ class T_picklefunction(unittest.TestCase):
# now put in a function with non-scalar
v_value
=
numpy
.
asarray
([
2
,
3
,
4.
],
dtype
=
config
.
floatX
)
f3
=
function
([
x
,
In
(
v
,
value
=
v_value
)],
x
+
v
)
f3
=
function
([
x
,
In
(
v
,
value
=
v_value
)],
x
+
v
)
list_of_things
.
append
(
f3
)
# try to pickle the entire things
...
...
@@ -777,16 +792,18 @@ class T_picklefunction(unittest.TestCase):
def
test_broken_pickle_with_shared
(
self
):
saves
=
[]
def
pers_save
(
obj
):
if
isinstance
(
obj
,
numpy
.
ndarray
):
saves
.
append
(
obj
)
return
len
(
saves
)
-
1
return
len
(
saves
)
-
1
else
:
return
None
def
pers_load
(
id
):
return
saves
[
id
]
a
=
numpy
.
random
.
rand
(
4
,
5
)
#
a = numpy.random.rand(4, 5)
b
=
numpy
.
random
.
rand
(
5
,
4
)
x
=
theano
.
tensor
.
matrix
()
...
...
@@ -809,7 +826,7 @@ class T_picklefunction(unittest.TestCase):
fp
.
close
()
p
=
pickle
.
Unpickler
(
fp2
)
p
.
persistent_load
=
pers_load
f2
=
p
.
load
()
#
f2 = p.load()
fp2
.
close
()
def
test_pickle_class_with_functions
(
self
):
...
...
@@ -845,9 +862,9 @@ class SomethingToPickle(object):
self
.
e
=
a
*
x
+
s
self
.
f1
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
self
.
f1
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
0.0
,
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
self
.
f2
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
self
.
f1
.
container
[
s
],
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
self
.
f2
=
function
([
x
,
In
(
a
,
value
=
1.0
,
name
=
'a'
),
In
(
s
,
value
=
self
.
f1
.
container
[
s
],
update
=
s
+
a
*
x
,
mutable
=
True
)],
s
+
a
*
x
)
def
test_empty_givens_updates
():
...
...
@@ -870,16 +887,17 @@ if __name__ == '__main__':
testcases
=
[]
testcases
.
append
(
T_function
)
#<testsuite boilerplate>
#
<testsuite boilerplate>
testloader
=
unittest
.
TestLoader
()
suite
=
unittest
.
TestSuite
()
for
testcase
in
testcases
:
suite
.
addTest
(
testloader
.
loadTestsFromTestCase
(
testcase
))
unittest
.
TextTestRunner
(
verbosity
=
2
)
.
run
(
suite
)
#</boilerplate>
#
</boilerplate>
elif
0
:
theano
.
config
.
mode
=
'FAST_COMPILE'
t
=
T_picklefunction
()
def
fu
(
b
):
assert
b
t
.
assertTrue
=
fu
...
...
theano/compile/tests/test_misc.py
浏览文件 @
0b5dbed9
import
numpy
,
theano
,
unittest
import
numpy
import
unittest
from
theano.compile.pfunc
import
pfunc
from
theano.compile.sharedvalue
import
shared
...
...
@@ -56,5 +57,7 @@ class TestNnet(unittest.TestCase):
# print 'Mean cost at epoch %s: %s' % (epoch, mean_cost)
self
.
assertTrue
(
abs
(
mean_cost
-
0.20588975452
)
<
1e-6
)
# Just call functions to make sure they do not crash.
out
=
nnet
.
compute_output
(
input
)
out
=
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
# out = nnet.compute_output(input)
# out = nnet.output_from_hidden(numpy.ones(10))
nnet
.
compute_output
(
input
)
nnet
.
output_from_hidden
(
numpy
.
ones
(
10
))
theano/compile/tests/test_monitormode.py
浏览文件 @
0b5dbed9
...
...
@@ -75,7 +75,7 @@ def test_not_inplace():
x
=
theano
.
tensor
.
vector
(
'x'
)
mode
=
theano
.
compile
.
MonitorMode
(
post_func
=
detect_nan
)
#mode = mode.excluding('fusion', 'inplace')
#
mode = mode.excluding('fusion', 'inplace')
mode
=
mode
.
excluding
(
'local_elemwise_fusion'
,
'inplace_elemwise_optimizer'
)
o
=
theano
.
tensor
.
outer
(
x
,
x
)
...
...
theano/compile/tests/test_pfunc.py
浏览文件 @
0b5dbed9
...
...
@@ -712,7 +712,7 @@ class Test_aliasing_rules(unittest.TestCase):
pass
from
theano.sparse
import
enable_sparse
if
enable_sparse
==
Fal
se
:
if
not
enable_spar
se
:
raise
SkipTest
(
'Optional package sparse disabled'
)
from
theano
import
sparse
...
...
@@ -816,9 +816,9 @@ class Test_aliasing_rules(unittest.TestCase):
theano
.
In
(
m1
,
mutable
=
True
),
theano
.
In
(
m2
,
mutable
=
True
),
theano
.
In
(
m3
,
mutable
=
True
)],
(
theano
.
dot
((
x
*
2
),
m1
)
+
theano
.
dot
((
y
*
3
),
m2
)
+
theano
.
dot
((
z
*
4
),
m3
)))
(
theano
.
dot
((
x
*
2
),
m1
)
+
theano
.
dot
((
y
*
3
),
m2
)
+
theano
.
dot
((
z
*
4
),
m3
)))
# Compute bogus values
v
=
numpy
.
asarray
([
1
,
2
,
3
,
4
,
5
],
dtype
=
'float64'
)
...
...
theano/compile/tests/test_profiling.py
浏览文件 @
0b5dbed9
...
...
@@ -44,7 +44,7 @@ class Test_profiling(unittest.TestCase):
mode
=
m
)
inp
=
[
numpy
.
arange
(
1024
,
dtype
=
'float32'
)
+
1
for
i
in
range
(
len
(
x
))]
output
=
f
(
*
inp
)
f
(
*
inp
)
buf
=
StringIO
()
f
.
profile
.
summary
(
buf
)
...
...
@@ -72,7 +72,6 @@ class Test_profiling(unittest.TestCase):
theano
.
config
.
profile_memory
=
config2
theano
.
config
.
profiling
.
min_peak_memory
=
config3
def
test_ifelse
(
self
):
config1
=
theano
.
config
.
profile
config2
=
theano
.
config
.
profile_memory
...
...
@@ -101,7 +100,8 @@ class Test_profiling(unittest.TestCase):
big_mat1
=
10
big_mat2
=
11
out
=
f_ifelse
(
val1
,
val2
,
big_mat1
,
big_mat2
)
# out = f_ifelse(val1, val2, big_mat1, big_mat2)
f_ifelse
(
val1
,
val2
,
big_mat1
,
big_mat2
)
finally
:
theano
.
config
.
profile
=
config1
...
...
theano/compile/tests/test_shared.py
浏览文件 @
0b5dbed9
...
...
@@ -31,8 +31,7 @@ class Test_SharedVariable(unittest.TestCase):
b
=
shared
(
numpy
.
random
.
rand
(
4
,
5
))
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
])
b
=
shared
(
numpy
.
random
.
rand
(
5
,
1
,
2
))
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
,
False
])
assert
b
.
type
==
TensorType
(
'float64'
,
broadcastable
=
[
False
,
False
,
False
])
assert
shared
([])
.
type
==
generic
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论