Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
7ed9fb90
提交
7ed9fb90
authored
7月 14, 2017
作者:
Pascal Lamblin
提交者:
GitHub
7月 14, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6111 from jhelie/fix-alerts-found-with-lgtm
Fix alerts found with lgtm
上级
c5a1cae2
f28febc1
隐藏空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
33 行增加
和
19 行删除
+33
-19
opt.py
theano/gof/opt.py
+3
-4
unify.py
theano/gof/unify.py
+3
-3
basic_ops.py
theano/gpuarray/basic_ops.py
+0
-1
subtensor.py
theano/gpuarray/subtensor.py
+2
-4
scan_utils.py
theano/scan_module/scan_utils.py
+1
-1
basic.py
theano/sparse/basic.py
+4
-1
opt.py
theano/sparse/opt.py
+1
-1
sp2.py
theano/sparse/sandbox/sp2.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+13
-0
var.py
theano/tensor/var.py
+5
-3
没有找到文件。
theano/gof/opt.py
浏览文件 @
7ed9fb90
...
@@ -56,8 +56,8 @@ class Optimizer(object):
...
@@ -56,8 +56,8 @@ class Optimizer(object):
# in subclasses from other bases.
# in subclasses from other bases.
return
id
(
self
)
==
id
(
other
)
return
id
(
self
)
==
id
(
other
)
def
__ne
q
__
(
self
,
other
):
def
__ne__
(
self
,
other
):
# added to override the __ne
q
__ implementation that may be inherited
# added to override the __ne__ implementation that may be inherited
# in subclasses from other bases.
# in subclasses from other bases.
return
id
(
self
)
!=
id
(
other
)
return
id
(
self
)
!=
id
(
other
)
...
@@ -492,8 +492,7 @@ class _metadict:
...
@@ -492,8 +492,7 @@ class _metadict:
except
Exception
:
except
Exception
:
if
item
is
item2
:
if
item
is
item2
:
return
value
return
value
else
:
return
default
return
default
def
clear
(
self
):
def
clear
(
self
):
self
.
d
=
{}
self
.
d
=
{}
...
...
theano/gof/unify.py
浏览文件 @
7ed9fb90
...
@@ -65,7 +65,7 @@ class BoundVariable(Variable):
...
@@ -65,7 +65,7 @@ class BoundVariable(Variable):
"""
"""
def
__init__
(
self
,
name
,
value
):
def
__init__
(
self
,
name
,
value
):
s
elf
.
name
=
name
s
uper
(
BoundVariable
,
self
)
.
__init__
(
name
=
name
)
self
.
value
=
value
self
.
value
=
value
...
@@ -77,7 +77,7 @@ class OrVariable(Variable):
...
@@ -77,7 +77,7 @@ class OrVariable(Variable):
"""
"""
def
__init__
(
self
,
name
,
options
):
def
__init__
(
self
,
name
,
options
):
s
elf
.
name
=
name
s
uper
(
OrVariable
,
self
)
.
__init__
(
name
=
name
)
self
.
options
=
options
self
.
options
=
options
...
@@ -89,7 +89,7 @@ class NotVariable(Variable):
...
@@ -89,7 +89,7 @@ class NotVariable(Variable):
"""
"""
def
__init__
(
self
,
name
,
not_options
):
def
__init__
(
self
,
name
,
not_options
):
s
elf
.
name
=
name
s
uper
(
NotVariable
,
self
)
.
__init__
(
name
=
name
)
self
.
not_options
=
not_options
self
.
not_options
=
not_options
...
...
theano/gpuarray/basic_ops.py
浏览文件 @
7ed9fb90
...
@@ -1315,7 +1315,6 @@ class GpuJoin(HideC, Join):
...
@@ -1315,7 +1315,6 @@ class GpuJoin(HideC, Join):
fail
=
sub
[
'fail'
]
fail
=
sub
[
'fail'
]
out
=
out_
[
0
]
out
=
out_
[
0
]
copy_inputs_to_list
=
'
\n
'
.
join
(
copy_to_list
)
copy_inputs_to_list
=
'
\n
'
.
join
(
copy_to_list
)
restype
=
restype
ctx
=
sub
[
'params'
]
ctx
=
sub
[
'params'
]
code
=
"""
code
=
"""
...
...
theano/gpuarray/subtensor.py
浏览文件 @
7ed9fb90
...
@@ -771,8 +771,7 @@ class GpuAdvancedIncSubtensor1(Op):
...
@@ -771,8 +771,7 @@ class GpuAdvancedIncSubtensor1(Op):
else
:
else
:
opname
=
'increment'
opname
=
'increment'
raise
TypeError
(
raise
TypeError
(
'cannot
%
s x subtensor with ndim=
%
s'
'cannot
%
s x subtensor with ndim=
%
s by y with ndim=
%
s '
%
(
' by y with ndim=
%
s to x subtensor with ndim=
%
s '
%
(
opname
,
x_
.
type
.
ndim
,
y_
.
type
.
ndim
))
opname
,
x_
.
type
.
ndim
,
y_
.
type
.
ndim
))
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
...
@@ -995,8 +994,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, HideC,
...
@@ -995,8 +994,7 @@ class GpuAdvancedIncSubtensor1_dev20(GpuKernelBase, HideC,
else
:
else
:
opname
=
'increment'
opname
=
'increment'
raise
TypeError
(
raise
TypeError
(
'cannot
%
s x subtensor with ndim=
%
s'
'cannot
%
s x subtensor with ndim=
%
s by y with ndim=
%
s '
%
(
' by y with ndim=
%
s to x subtensor with ndim=
%
s '
%
(
opname
,
x_
.
type
.
ndim
,
y_
.
type
.
ndim
))
opname
,
x_
.
type
.
ndim
,
y_
.
type
.
ndim
))
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
return
gof
.
Apply
(
self
,
[
x_
,
y_
,
ilist_
],
[
x_
.
type
()])
...
...
theano/scan_module/scan_utils.py
浏览文件 @
7ed9fb90
...
@@ -56,7 +56,7 @@ def safe_new(x, tag='', dtype=None):
...
@@ -56,7 +56,7 @@ def safe_new(x, tag='', dtype=None):
if
dtype
and
x
.
dtype
!=
dtype
:
if
dtype
and
x
.
dtype
!=
dtype
:
casted_x
=
x
.
astype
(
dtype
)
casted_x
=
x
.
astype
(
dtype
)
nwx
=
x
.
__class__
(
casted_x
.
type
,
x
.
data
,
x
.
name
)
nwx
=
x
.
__class__
(
casted_x
.
type
,
x
.
data
,
x
.
name
)
nwx
.
tag
=
copy
(
x
.
tag
)
nwx
.
tag
=
copy
.
copy
(
x
.
tag
)
return
nwx
return
nwx
else
:
else
:
return
x
.
clone
()
return
x
.
clone
()
...
...
theano/sparse/basic.py
浏览文件 @
7ed9fb90
...
@@ -333,6 +333,9 @@ class SparseConstantSignature(tuple):
...
@@ -333,6 +333,9 @@ class SparseConstantSignature(tuple):
(
b
.
shape
==
y
.
shape
)
and
(
b
.
shape
==
y
.
shape
)
and
(
abs
(
b
-
y
)
.
sum
()
<
1e-6
*
b
.
nnz
))
(
abs
(
b
-
y
)
.
sum
()
<
1e-6
*
b
.
nnz
))
def
__ne__
(
self
,
other
):
return
not
self
==
other
def
__hash__
(
self
):
def
__hash__
(
self
):
(
a
,
b
)
=
self
(
a
,
b
)
=
self
return
hash
(
type
(
self
))
^
hash
(
a
)
^
hash
(
type
(
b
))
return
hash
(
type
(
self
))
^
hash
(
a
)
^
hash
(
type
(
b
))
...
@@ -1330,7 +1333,7 @@ class GetItemScalar(gof.op.Op):
...
@@ -1330,7 +1333,7 @@ class GetItemScalar(gof.op.Op):
elif
ind
.
ndim
==
0
:
elif
ind
.
ndim
==
0
:
input_op
+=
[
ind
]
input_op
+=
[
ind
]
else
:
else
:
raise
NotImplemented
()
raise
NotImplemented
Error
return
gof
.
Apply
(
self
,
input_op
,
[
tensor
.
scalar
(
dtype
=
x
.
dtype
)])
return
gof
.
Apply
(
self
,
input_op
,
[
tensor
.
scalar
(
dtype
=
x
.
dtype
)])
...
...
theano/sparse/opt.py
浏览文件 @
7ed9fb90
...
@@ -1350,7 +1350,7 @@ def local_mul_s_d(node):
...
@@ -1350,7 +1350,7 @@ def local_mul_s_d(node):
CSx
=
sparse
.
CSR
CSx
=
sparse
.
CSR
mul_s_d_csx
=
mul_s_d_csr
mul_s_d_csx
=
mul_s_d_csr
else
:
else
:
raise
NotImplemented
()
raise
NotImplemented
Error
if
x
.
dtype
!=
y
.
dtype
:
if
x
.
dtype
!=
y
.
dtype
:
# mul_s_d_csx don't support that case
# mul_s_d_csx don't support that case
return
return
...
...
theano/sparse/sandbox/sp2.py
浏览文件 @
7ed9fb90
...
@@ -194,7 +194,7 @@ class Multinomial(gof.op.Op):
...
@@ -194,7 +194,7 @@ class Multinomial(gof.op.Op):
assert
_is_sparse
(
p
)
assert
_is_sparse
(
p
)
if
p
.
format
!=
'csr'
:
if
p
.
format
!=
'csr'
:
raise
NotImplemented
()
raise
NotImplemented
Error
out
[
0
]
=
p
.
copy
()
out
[
0
]
=
p
.
copy
()
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
7ed9fb90
...
@@ -8386,6 +8386,19 @@ class T_Choose(utt.InferShapeTester):
...
@@ -8386,6 +8386,19 @@ class T_Choose(utt.InferShapeTester):
n_c
=
np
.
choose
(
A
,
B
,
mode
=
m
)
n_c
=
np
.
choose
(
A
,
B
,
mode
=
m
)
assert
np
.
allclose
(
t_c
,
n_c
)
assert
np
.
allclose
(
t_c
,
n_c
)
def
test_method
(
self
):
a
=
tensor
.
vector
(
dtype
=
'int32'
)
b
=
tensor
.
matrix
(
dtype
=
'float32'
)
A
=
np
.
random
.
randint
(
0
,
4
,
4
)
.
astype
(
'int32'
)
B
=
np
.
asarray
(
np
.
random
.
rand
(
4
,
4
),
dtype
=
'float32'
)
for
m
in
self
.
modes
:
f
=
function
([
a
,
b
],
a
.
choose
(
b
,
mode
=
m
))
t_c
=
f
(
A
,
B
)
n_c
=
A
.
choose
(
B
,
mode
=
m
)
assert
np
.
allclose
(
t_c
,
n_c
)
def
test_broadcasted
(
self
):
def
test_broadcasted
(
self
):
a
=
tensor
.
scalar
(
dtype
=
'int32'
)
a
=
tensor
.
scalar
(
dtype
=
'int32'
)
b
=
tensor
.
matrix
(
dtype
=
'float32'
)
b
=
tensor
.
matrix
(
dtype
=
'float32'
)
...
...
theano/tensor/var.py
浏览文件 @
7ed9fb90
...
@@ -762,14 +762,13 @@ class _tensor_py_operators(object):
...
@@ -762,14 +762,13 @@ class _tensor_py_operators(object):
"""Fill inputted tensor with the assigned value."""
"""Fill inputted tensor with the assigned value."""
return
theano
.
tensor
.
basic
.
fill
(
self
,
value
)
return
theano
.
tensor
.
basic
.
fill
(
self
,
value
)
def
choose
(
self
,
a
,
choices
,
out
=
None
,
mode
=
'raise'
):
def
choose
(
self
,
choices
,
out
=
None
,
mode
=
'raise'
):
"""
"""
Construct an array from an index array and a set of arrays to choose
Construct an array from an index array and a set of arrays to choose
from.
from.
"""
"""
return
theano
.
tensor
.
basic
.
choose
(
self
,
a
,
choices
,
out
=
None
,
return
theano
.
tensor
.
basic
.
choose
(
self
,
choices
,
out
=
None
,
mode
=
'raise'
)
mode
=
'raise'
)
def
squeeze
(
self
):
def
squeeze
(
self
):
"""
"""
...
@@ -864,6 +863,9 @@ class TensorConstantSignature(tuple):
...
@@ -864,6 +863,9 @@ class TensorConstantSignature(tuple):
# here).
# here).
return
(
self
.
sum
==
other
.
sum
)
and
np
.
all
(
d0
==
d1
)
return
(
self
.
sum
==
other
.
sum
)
and
np
.
all
(
d0
==
d1
)
def
__ne__
(
self
,
other
):
return
not
self
==
other
def
__hash__
(
self
):
def
__hash__
(
self
):
t
,
d
=
self
t
,
d
=
self
return
hashtype
(
self
)
^
hash
(
t
)
^
hash
(
d
.
shape
)
^
hash
(
self
.
sum
)
return
hashtype
(
self
)
^
hash
(
t
)
^
hash
(
d
.
shape
)
^
hash
(
self
.
sum
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论