Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a6fead02
提交
a6fead02
authored
3月 06, 2013
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Pep8 / Pyflakes
上级
872c8166
显示空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
78 行增加
和
37 行删除
+78
-37
__init__.py
theano/gof/__init__.py
+0
-1
cmodule.py
theano/gof/cmodule.py
+6
-6
utils.py
theano/gof/utils.py
+69
-25
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+0
-3
extra_ops.py
theano/tensor/extra_ops.py
+1
-1
test_extra_ops.py
theano/tensor/tests/test_extra_ops.py
+2
-1
没有找到文件。
theano/gof/__init__.py
浏览文件 @
a6fead02
...
@@ -79,4 +79,3 @@ from theano.gof.type import \
...
@@ -79,4 +79,3 @@ from theano.gof.type import \
from
theano.gof.utils
import
\
from
theano.gof.utils
import
\
object2
,
MethodNotDefined
object2
,
MethodNotDefined
theano/gof/cmodule.py
浏览文件 @
a6fead02
...
@@ -8,7 +8,6 @@ import os
...
@@ -8,7 +8,6 @@ import os
import
shutil
import
shutil
import
stat
import
stat
import
StringIO
import
StringIO
import
struct
import
subprocess
import
subprocess
import
sys
import
sys
import
tempfile
import
tempfile
...
@@ -153,14 +152,14 @@ static struct PyModuleDef moduledef = {{
...
@@ -153,14 +152,14 @@ static struct PyModuleDef moduledef = {{
}};
}};
"""
.
format
(
name
=
self
.
name
)
"""
.
format
(
name
=
self
.
name
)
print
>>
stream
,
"PyMODINIT_FUNC PyInit_
%
s(void) {"
%
self
.
name
print
>>
stream
,
"PyMODINIT_FUNC PyInit_
%
s(void) {"
%
self
.
name
for
b
in
self
.
init_blocks
:
for
b
lock
in
self
.
init_blocks
:
print
>>
stream
,
' '
,
b
print
>>
stream
,
' '
,
b
lock
print
>>
stream
,
" PyObject *m = PyModule_Create(&moduledef);"
print
>>
stream
,
" PyObject *m = PyModule_Create(&moduledef);"
print
>>
stream
,
" return m;"
print
>>
stream
,
" return m;"
else
:
else
:
print
>>
stream
,
"PyMODINIT_FUNC init
%
s(void){"
%
self
.
name
print
>>
stream
,
"PyMODINIT_FUNC init
%
s(void){"
%
self
.
name
for
b
in
self
.
init_blocks
:
for
b
lock
in
self
.
init_blocks
:
print
>>
stream
,
' '
,
b
print
>>
stream
,
' '
,
b
lock
print
>>
stream
,
' '
,
(
'(void) Py_InitModule("
%
s", MyMethods);'
print
>>
stream
,
' '
,
(
'(void) Py_InitModule("
%
s", MyMethods);'
%
self
.
name
)
%
self
.
name
)
print
>>
stream
,
"}"
print
>>
stream
,
"}"
...
@@ -1541,7 +1540,8 @@ class GCC_compiler(object):
...
@@ -1541,7 +1540,8 @@ class GCC_compiler(object):
lines
=
stdout
+
stderr
lines
=
stdout
+
stderr
return
lines
return
lines
# The '-' at the end is needed. Otherwise, g++ do not output enough information.
# The '-' at the end is needed. Otherwise, g++ do not output
# enough information.
native_lines
=
get_lines
(
"g++ -march=native -E -v -"
)
native_lines
=
get_lines
(
"g++ -march=native -E -v -"
)
_logger
.
info
(
"g++ -march=native selected lines:
%
s"
,
native_lines
)
_logger
.
info
(
"g++ -march=native selected lines:
%
s"
,
native_lines
)
if
len
(
native_lines
)
!=
1
:
if
len
(
native_lines
)
!=
1
:
...
...
theano/gof/utils.py
浏览文件 @
a6fead02
import
re
# import op
import
traceback
# import variable
from
theano
import
config
from
theano
import
config
import
re
,
traceback
def
add_tag_trace
(
thing
):
def
add_tag_trace
(
thing
):
"""Add tag.trace to an node or variable.
"""Add tag.trace to an node or variable.
...
@@ -11,15 +10,18 @@ def add_tag_trace(thing):
...
@@ -11,15 +10,18 @@ def add_tag_trace(thing):
The argument is returned after being affected (inplace).
The argument is returned after being affected (inplace).
"""
"""
limit
=
config
.
traceback
.
limit
limit
=
config
.
traceback
.
limit
if
limit
==
-
1
:
limit
=
None
if
limit
==
-
1
:
limit
=
None
thing
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
thing
.
tag
.
trace
=
traceback
.
extract_stack
(
limit
=
limit
)[:
-
1
]
return
thing
return
thing
def
hashgen
():
def
hashgen
():
hashgen
.
next
+=
1
hashgen
.
next
+=
1
return
hashgen
.
next
return
hashgen
.
next
hashgen
.
next
=
0
hashgen
.
next
=
0
class
MethodNotDefined
(
Exception
):
class
MethodNotDefined
(
Exception
):
"""
"""
To be raised by functions defined as part of an interface.
To be raised by functions defined as part of an interface.
...
@@ -28,6 +30,7 @@ class MethodNotDefined(Exception):
...
@@ -28,6 +30,7 @@ class MethodNotDefined(Exception):
function has been left out of an implementation class.
function has been left out of an implementation class.
"""
"""
class
object2
(
object
):
class
object2
(
object
):
__slots__
=
[]
__slots__
=
[]
if
0
:
if
0
:
...
@@ -36,23 +39,30 @@ class object2(object):
...
@@ -36,23 +39,30 @@ class object2(object):
if
hasattr
(
self
,
'__eq__'
)
or
hasattr
(
self
,
'__cmp__'
):
if
hasattr
(
self
,
'__eq__'
)
or
hasattr
(
self
,
'__cmp__'
):
raise
TypeError
(
"unhashable object:
%
s"
%
self
)
raise
TypeError
(
"unhashable object:
%
s"
%
self
)
return
id
(
self
)
return
id
(
self
)
def
__ne__
(
self
,
other
):
def
__ne__
(
self
,
other
):
return
not
self
==
other
return
not
self
==
other
class
scratchpad
:
class
scratchpad
:
def
clear
(
self
):
def
clear
(
self
):
self
.
__dict__
.
clear
()
self
.
__dict__
.
clear
()
def
__update__
(
self
,
other
):
def
__update__
(
self
,
other
):
self
.
__dict__
.
update
(
other
.
__dict__
)
self
.
__dict__
.
update
(
other
.
__dict__
)
return
self
return
self
def
__str__
(
self
):
def
__str__
(
self
):
return
"scratchpad"
+
str
(
self
.
__dict__
)
return
"scratchpad"
+
str
(
self
.
__dict__
)
def
__repr__
(
self
):
def
__repr__
(
self
):
return
"scratchpad"
+
str
(
self
.
__dict__
)
return
"scratchpad"
+
str
(
self
.
__dict__
)
def
info
(
self
):
def
info
(
self
):
print
"<theano.gof.utils.scratchpad instance at
%
i>"
%
id
(
self
)
print
"<theano.gof.utils.scratchpad instance at
%
i>"
%
id
(
self
)
for
k
,
v
in
self
.
__dict__
.
items
():
for
k
,
v
in
self
.
__dict__
.
items
():
print
"
%
s:
%
s"
%
(
k
,
v
)
print
"
%
s:
%
s"
%
(
k
,
v
)
class
D
:
class
D
:
def
__init__
(
self
,
**
d
):
def
__init__
(
self
,
**
d
):
...
@@ -63,6 +73,7 @@ def memoize(f):
...
@@ -63,6 +73,7 @@ def memoize(f):
"""Cache the return value for each tuple of arguments
"""Cache the return value for each tuple of arguments
(which must be hashable) """
(which must be hashable) """
cache
=
{}
cache
=
{}
def
rval
(
*
args
,
**
kwargs
):
def
rval
(
*
args
,
**
kwargs
):
kwtup
=
tuple
(
kwargs
.
items
())
kwtup
=
tuple
(
kwargs
.
items
())
key
=
(
args
,
kwtup
)
key
=
(
args
,
kwtup
)
...
@@ -72,8 +83,8 @@ def memoize(f):
...
@@ -72,8 +83,8 @@ def memoize(f):
else
:
else
:
val
=
cache
[
key
]
val
=
cache
[
key
]
return
val
return
val
return
rval
return
rval
def
deprecated
(
filename
,
msg
=
''
):
def
deprecated
(
filename
,
msg
=
''
):
...
@@ -92,6 +103,7 @@ def deprecated(filename, msg=''):
...
@@ -92,6 +103,7 @@ def deprecated(filename, msg=''):
"""
"""
def
_deprecated
(
f
):
def
_deprecated
(
f
):
printme
=
[
True
]
printme
=
[
True
]
def
g
(
*
args
,
**
kwargs
):
def
g
(
*
args
,
**
kwargs
):
if
printme
[
0
]:
if
printme
[
0
]:
print
'WARNING:
%
s.
%
s deprecated.
%
s'
\
print
'WARNING:
%
s.
%
s deprecated.
%
s'
\
...
@@ -99,12 +111,16 @@ def deprecated(filename, msg=''):
...
@@ -99,12 +111,16 @@ def deprecated(filename, msg=''):
printme
[
0
]
=
False
printme
[
0
]
=
False
return
f
(
*
args
,
**
kwargs
)
return
f
(
*
args
,
**
kwargs
)
return
g
return
g
return
_deprecated
return
_deprecated
def
uniq
(
seq
):
def
uniq
(
seq
):
#TODO: consider building a set out of seq so that the if condition is constant time -JB
#TODO: consider building a set out of seq so that the if condition
#is constant time -JB
return
[
x
for
i
,
x
in
enumerate
(
seq
)
if
seq
.
index
(
x
)
==
i
]
return
[
x
for
i
,
x
in
enumerate
(
seq
)
if
seq
.
index
(
x
)
==
i
]
def
difference
(
seq1
,
seq2
):
def
difference
(
seq1
,
seq2
):
"""
"""
Returns all elements in seq1 which are not in seq2: i.e seq1
\
seq2
Returns all elements in seq1 which are not in seq2: i.e seq1
\
seq2
...
@@ -132,13 +148,16 @@ def partition(f, seq):
...
@@ -132,13 +148,16 @@ def partition(f, seq):
seqf
.
append
(
elem
)
seqf
.
append
(
elem
)
return
seqt
,
seqf
return
seqt
,
seqf
def
attr_checker
(
*
attrs
):
def
attr_checker
(
*
attrs
):
def
f
(
candidate
):
def
f
(
candidate
):
for
attr
in
attrs
:
for
attr
in
attrs
:
if
not
hasattr
(
candidate
,
attr
):
if
not
hasattr
(
candidate
,
attr
):
return
False
return
False
return
True
return
True
f
.
__doc__
=
"Checks that the candidate has the following attributes:
%
s"
%
", "
.
join
([
"'
%
s'"
%
attr
for
attr
in
attrs
])
f
.
__doc__
=
(
"Checks that the candidate has the following attributes:
%
s"
%
", "
.
join
([
"'
%
s'"
%
attr
for
attr
in
attrs
]))
return
f
return
f
...
@@ -149,7 +168,6 @@ def all_bases(cls, accept):
...
@@ -149,7 +168,6 @@ def all_bases(cls, accept):
return
[
cls
for
cls
in
rval
if
accept
(
cls
)]
return
[
cls
for
cls
in
rval
if
accept
(
cls
)]
def
all_bases_collect
(
cls
,
raw_name
):
def
all_bases_collect
(
cls
,
raw_name
):
rval
=
set
()
rval
=
set
()
name
=
"__
%
s__"
%
raw_name
name
=
"__
%
s__"
%
raw_name
...
@@ -162,7 +180,7 @@ def all_bases_collect(cls, raw_name):
...
@@ -162,7 +180,7 @@ def all_bases_collect(cls, raw_name):
return
rval
return
rval
def
camelcase_to_separated
(
string
,
sep
=
"_"
):
def
camelcase_to_separated
(
string
,
sep
=
"_"
):
return
re
.
sub
(
'(.)([A-Z])'
,
'
\\
1
%
s
\\
2'
%
sep
,
string
)
.
lower
()
return
re
.
sub
(
'(.)([A-Z])'
,
'
\\
1
%
s
\\
2'
%
sep
,
string
)
.
lower
()
...
@@ -172,6 +190,7 @@ def to_return_values(values):
...
@@ -172,6 +190,7 @@ def to_return_values(values):
else
:
else
:
return
values
return
values
def
from_return_values
(
values
):
def
from_return_values
(
values
):
if
isinstance
(
values
,
(
list
,
tuple
)):
if
isinstance
(
values
,
(
list
,
tuple
)):
return
values
return
values
...
@@ -186,7 +205,8 @@ class ClsInit(type):
...
@@ -186,7 +205,8 @@ class ClsInit(type):
Validate and initialize the L{Op} subclass 'cls'
Validate and initialize the L{Op} subclass 'cls'
This function:
This function:
- changes class attributes input_names and output_names to be lists if they are single strings.
- changes class attributes input_names and output_names to be lists
if they are single strings.
"""
"""
type
.
__init__
(
cls
,
name
,
bases
,
dct
)
type
.
__init__
(
cls
,
name
,
bases
,
dct
)
...
@@ -195,8 +215,10 @@ class ClsInit(type):
...
@@ -195,8 +215,10 @@ class ClsInit(type):
def
toposort
(
prereqs_d
):
def
toposort
(
prereqs_d
):
"""
"""
Sorts prereqs_d.keys() topologically. prereqs_d[x] contains all the elements
Sorts prereqs_d.keys() topologically.
that must come before x in the ordering.
prereqs_d[x] contains all the elements that must come before x
in the ordering.
"""
"""
# all1 = set(prereqs_d.keys())
# all1 = set(prereqs_d.keys())
...
@@ -223,19 +245,26 @@ def toposort(prereqs_d):
...
@@ -223,19 +245,26 @@ def toposort(prereqs_d):
if
not
prereqs_d
[
postreq
]
.
difference
(
done
):
if
not
prereqs_d
[
postreq
]
.
difference
(
done
):
next
.
add
(
postreq
)
next
.
add
(
postreq
)
if
len
(
prereqs_d
)
!=
len
(
seq
):
if
len
(
prereqs_d
)
!=
len
(
seq
):
raise
Exception
(
"Cannot sort topologically: there might be cycles, "
+
\
raise
Exception
(
"Cannot sort topologically: there might be cycles, "
"prereqs_d does not have a key for each element or "
+
\
"prereqs_d does not have a key for each element or "
"some orderings contain invalid elements."
)
"some orderings contain invalid elements."
)
return
seq
return
seq
def
print_for_dot
(
self
):
def
print_for_dot
(
self
):
#TODO: popen2("dot -Tpng | display") and actually make the graph window pop up
#TODO: popen2("dot -Tpng | display") and actually make the graph window
print
"digraph unix { size = '6,6'; node [color = lightblue2; style = filled];"
#pop up
print
(
"digraph unix { size = '6,6'; node [color = lightblue2;"
"style = filled];"
)
for
op
in
self
.
order
:
for
op
in
self
.
order
:
for
input
in
op
.
inputs
:
for
input
in
op
.
inputs
:
if
input
.
owner
:
if
input
.
owner
:
print
input
.
owner
.
__class__
.
__name__
+
str
(
abs
(
id
(
input
.
owner
))),
" -> "
,
op
.
__class__
.
__name__
+
str
(
abs
(
id
(
op
))),
";"
print
' '
.
join
((
input
.
owner
.
__class__
.
__name__
+
str
(
abs
(
id
(
input
.
owner
))),
" -> "
,
op
.
__class__
.
__name__
+
str
(
abs
(
id
(
op
))),
";"
))
class
Keyword
:
class
Keyword
:
...
@@ -263,9 +292,11 @@ simple_types = (int, float, str, bool, None.__class__, Keyword)
...
@@ -263,9 +292,11 @@ simple_types = (int, float, str, bool, None.__class__, Keyword)
ANY_TYPE
=
Keyword
(
"ANY_TYPE"
)
ANY_TYPE
=
Keyword
(
"ANY_TYPE"
)
FALL_THROUGH
=
Keyword
(
"FALL_THROUGH"
)
FALL_THROUGH
=
Keyword
(
"FALL_THROUGH"
)
def
comm_guard
(
type1
,
type2
):
def
comm_guard
(
type1
,
type2
):
def
wrap
(
f
):
def
wrap
(
f
):
old_f
=
f
.
func_globals
[
f
.
__name__
]
old_f
=
f
.
func_globals
[
f
.
__name__
]
def
new_f
(
arg1
,
arg2
,
*
rest
):
def
new_f
(
arg1
,
arg2
,
*
rest
):
if
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
))
\
if
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
))
\
and
(
type2
is
ANY_TYPE
or
isinstance
(
arg2
,
type2
)):
and
(
type2
is
ANY_TYPE
or
isinstance
(
arg2
,
type2
)):
...
@@ -283,6 +314,7 @@ def comm_guard(type1, type2):
...
@@ -283,6 +314,7 @@ def comm_guard(type1, type2):
return
variable
return
variable
new_f
.
__name__
=
f
.
__name__
new_f
.
__name__
=
f
.
__name__
def
typename
(
type
):
def
typename
(
type
):
if
isinstance
(
type
,
Keyword
):
if
isinstance
(
type
,
Keyword
):
return
str
(
type
)
return
str
(
type
)
...
@@ -290,14 +322,19 @@ def comm_guard(type1, type2):
...
@@ -290,14 +322,19 @@ def comm_guard(type1, type2):
return
"("
+
", "
.
join
([
x
.
__name__
for
x
in
type
])
+
")"
return
"("
+
", "
.
join
([
x
.
__name__
for
x
in
type
])
+
")"
else
:
else
:
return
type
.
__name__
return
type
.
__name__
new_f
.
__doc__
=
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,
type2
)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
)
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,
type2
)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
))
return
new_f
return
new_f
return
wrap
return
wrap
def
type_guard
(
type1
):
def
type_guard
(
type1
):
def
wrap
(
f
):
def
wrap
(
f
):
old_f
=
f
.
func_globals
[
f
.
__name__
]
old_f
=
f
.
func_globals
[
f
.
__name__
]
def
new_f
(
arg1
,
*
rest
):
def
new_f
(
arg1
,
*
rest
):
if
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
)):
if
(
type1
is
ANY_TYPE
or
isinstance
(
arg1
,
type1
)):
variable
=
f
(
arg1
,
*
rest
)
variable
=
f
(
arg1
,
*
rest
)
...
@@ -308,8 +345,8 @@ def type_guard(type1):
...
@@ -308,8 +345,8 @@ def type_guard(type1):
else
:
else
:
return
old_f
(
arg1
,
*
rest
)
return
old_f
(
arg1
,
*
rest
)
new_f
.
__name__
=
f
.
__name__
new_f
.
__name__
=
f
.
__name__
def
typename
(
type
):
def
typename
(
type
):
if
isinstance
(
type
,
Keyword
):
if
isinstance
(
type
,
Keyword
):
return
str
(
type
)
return
str
(
type
)
...
@@ -317,8 +354,12 @@ def type_guard(type1):
...
@@ -317,8 +354,12 @@ def type_guard(type1):
return
"("
+
", "
.
join
([
x
.
__name__
for
x
in
type
])
+
")"
return
"("
+
", "
.
join
([
x
.
__name__
for
x
in
type
])
+
")"
else
:
else
:
return
type
.
__name__
return
type
.
__name__
new_f
.
__doc__
=
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
)
new_f
.
__doc__
=
(
str
(
old_f
.
__doc__
)
+
"
\n
"
+
", "
.
join
([
typename
(
type
)
for
type
in
(
type1
,)])
+
"
\n
"
+
str
(
f
.
__doc__
or
""
))
return
new_f
return
new_f
return
wrap
return
wrap
...
@@ -331,15 +372,18 @@ def flatten(a):
...
@@ -331,15 +372,18 @@ def flatten(a):
else
:
else
:
return
[
a
]
return
[
a
]
def
unique
(
x
):
def
unique
(
x
):
return
len
(
set
(
x
))
==
len
(
x
)
return
len
(
set
(
x
))
==
len
(
x
)
def
hist
(
coll
):
def
hist
(
coll
):
counts
=
{}
counts
=
{}
for
elem
in
coll
:
for
elem
in
coll
:
counts
[
elem
]
=
counts
.
get
(
elem
,
0
)
+
1
counts
[
elem
]
=
counts
.
get
(
elem
,
0
)
+
1
return
counts
return
counts
def
give_variables_names
(
variables
):
def
give_variables_names
(
variables
):
""" Gives unique names to an iterable of variables. Modifies input.
""" Gives unique names to an iterable of variables. Modifies input.
...
@@ -349,7 +393,7 @@ def give_variables_names(variables):
...
@@ -349,7 +393,7 @@ def give_variables_names(variables):
bad_var
=
lambda
var
:
not
var
.
name
or
h
[
var
.
name
]
>
1
bad_var
=
lambda
var
:
not
var
.
name
or
h
[
var
.
name
]
>
1
for
i
,
var
in
enumerate
(
filter
(
bad_var
,
variables
)):
for
i
,
var
in
enumerate
(
filter
(
bad_var
,
variables
)):
var
.
name
=
(
var
.
name
or
""
)
+
"_
%
d"
%
i
var
.
name
=
(
var
.
name
or
""
)
+
"_
%
d"
%
i
if
not
unique
(
map
(
str
,
variables
)):
if
not
unique
(
map
(
str
,
variables
)):
raise
ValueError
(
"Not all variables have unique names."
raise
ValueError
(
"Not all variables have unique names."
...
...
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
a6fead02
...
@@ -9,7 +9,6 @@ import warnings
...
@@ -9,7 +9,6 @@ import warnings
import
numpy
import
numpy
import
theano
from
theano.gof
import
local_bitwidth
from
theano.gof
import
local_bitwidth
from
theano.gof.cc
import
hash_from_file
from
theano.gof.cc
import
hash_from_file
from
theano.gof.cmodule
import
(
std_libs
,
std_lib_dirs
,
from
theano.gof.cmodule
import
(
std_libs
,
std_lib_dirs
,
...
@@ -246,8 +245,6 @@ class NVCC_compiler(object):
...
@@ -246,8 +245,6 @@ class NVCC_compiler(object):
cppfile
=
file
(
cppfilename
,
'w'
)
cppfile
=
file
(
cppfilename
,
'w'
)
_logger
.
debug
(
'Writing module C++ code to
%
s'
,
cppfilename
)
_logger
.
debug
(
'Writing module C++ code to
%
s'
,
cppfilename
)
ofiles
=
[]
rval
=
None
cppfile
.
write
(
src_code
)
cppfile
.
write
(
src_code
)
cppfile
.
close
()
cppfile
.
close
()
...
...
theano/tensor/extra_ops.py
浏览文件 @
a6fead02
...
@@ -259,7 +259,7 @@ class RepeatOp(theano.Op):
...
@@ -259,7 +259,7 @@ class RepeatOp(theano.Op):
%
numpy_unsupported_dtypes
),
repeats
.
dtype
)
%
numpy_unsupported_dtypes
),
repeats
.
dtype
)
if
self
.
axis
is
None
:
if
self
.
axis
is
None
:
broadcastable
=
[
False
]
broadcastable
=
[
False
]
else
:
else
:
try
:
try
:
const_reps
=
basic
.
get_scalar_constant_value
(
repeats
)
const_reps
=
basic
.
get_scalar_constant_value
(
repeats
)
...
...
theano/tensor/tests/test_extra_ops.py
浏览文件 @
a6fead02
...
@@ -13,6 +13,7 @@ from theano import config, tensor, function
...
@@ -13,6 +13,7 @@ from theano import config, tensor, function
numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
numpy_16
=
bool
(
numpy_ver
>=
[
1
,
6
])
numpy_16
=
bool
(
numpy_ver
>=
[
1
,
6
])
class
TestBinCountOp
(
utt
.
InferShapeTester
):
class
TestBinCountOp
(
utt
.
InferShapeTester
):
def
setUp
(
self
):
def
setUp
(
self
):
super
(
TestBinCountOp
,
self
)
.
setUp
()
super
(
TestBinCountOp
,
self
)
.
setUp
()
...
@@ -188,7 +189,6 @@ class SqueezeTester(utt.InferShapeTester):
...
@@ -188,7 +189,6 @@ class SqueezeTester(utt.InferShapeTester):
def
test_grad
(
self
):
def
test_grad
(
self
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
for
shape
,
broadcast
in
zip
(
self
.
shape_list
,
self
.
broadcast_list
):
data
=
numpy
.
random
.
random
(
size
=
shape
)
.
astype
(
theano
.
config
.
floatX
)
data
=
numpy
.
random
.
random
(
size
=
shape
)
.
astype
(
theano
.
config
.
floatX
)
variable
=
tensor
.
TensorType
(
theano
.
config
.
floatX
,
broadcast
)()
utt
.
verify_grad
(
self
.
op
,
[
data
])
utt
.
verify_grad
(
self
.
op
,
[
data
])
...
@@ -292,6 +292,7 @@ class TestRepeatOp(utt.InferShapeTester):
...
@@ -292,6 +292,7 @@ class TestRepeatOp(utt.InferShapeTester):
r
=
RepeatOp
(
axis
=
0
)(
x
,
2
)
r
=
RepeatOp
(
axis
=
0
)(
x
,
2
)
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
self
.
assertEqual
(
r
.
broadcastable
,
(
False
,
True
,
False
))
class
TestBartlett
(
utt
.
InferShapeTester
):
class
TestBartlett
(
utt
.
InferShapeTester
):
def
setUp
(
self
):
def
setUp
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论