Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
e829ba4f
提交
e829ba4f
authored
2月 13, 2017
作者:
Pascal Lamblin
提交者:
GitHub
2月 13, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5527 from lamblin/ccw_numpy_travis
validate numpy1.12 compatibility changes
上级
9f1aaacb
848fae56
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
43 行增加
和
13 行删除
+43
-13
.travis.yml
.travis.yml
+2
-1
fft.txt
doc/library/tensor/fft.txt
+1
-1
cc.py
theano/gof/cc.py
+1
-4
elemwise.py
theano/gpuarray/elemwise.py
+2
-2
basic.py
theano/scalar/basic.py
+5
-1
basic.py
theano/tensor/basic.py
+4
-1
elemwise.py
theano/tensor/elemwise.py
+11
-2
test_elemwise.py
theano/tensor/tests/test_elemwise.py
+17
-1
没有找到文件。
.travis.yml
浏览文件 @
e829ba4f
...
@@ -48,7 +48,8 @@ env:
...
@@ -48,7 +48,8 @@ env:
-
PART="-e test_flake8.py theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/sparse theano/tests theano/typed_list"
-
PART="-e test_flake8.py theano/compat theano/compile theano/d3viz theano/gof theano/misc theano/sandbox theano/scalar theano/scan_module theano/sparse theano/tests theano/typed_list"
-
PART="theano/tensor -e test_basic.py --exclude-dir=theano/tensor/nnet"
-
PART="theano/tensor -e test_basic.py --exclude-dir=theano/tensor/nnet"
-
PART="theano/tensor/tests/test_basic.py"
-
PART="theano/tensor/tests/test_basic.py"
-
PART="theano/tensor/nnet"
-
PART="theano/tensor/nnet -e test_abstract_conv.py"
-
PART="theano/tensor/nnet/tests/test_abstract_conv.py"
matrix
:
matrix
:
fast_finish
:
true
fast_finish
:
true
...
...
doc/library/tensor/fft.txt
浏览文件 @
e829ba4f
...
@@ -34,7 +34,7 @@ oscillates due to the box function being shifted to the middle of the array.
...
@@ -34,7 +34,7 @@ oscillates due to the box function being shifted to the middle of the array.
N = 1024
N = 1024
box = np.zeros((1, N), dtype='float64')
box = np.zeros((1, N), dtype='float64')
box[:, N/
2-10: N
/2+10] = 1
box[:, N/
/2-10: N/
/2+10] = 1
out = f_rfft(box)
out = f_rfft(box)
c_out = np.asarray(out[0, :, 0] + 1j*out[0, :, 1])
c_out = np.asarray(out[0, :, 0] + 1j*out[0, :, 1])
...
...
theano/gof/cc.py
浏览文件 @
e829ba4f
...
@@ -1412,11 +1412,8 @@ class CLinker(link.Linker):
...
@@ -1412,11 +1412,8 @@ class CLinker(link.Linker):
version
=
[]
version
=
[]
for
node_pos
,
node
in
enumerate
(
order
):
for
node_pos
,
node
in
enumerate
(
order
):
try
:
if
hasattr
(
node
.
op
,
'c_code_cache_version_apply'
):
# Pure Ops do not have a c_code_cache_version_apply ...
version
.
append
(
node
.
op
.
c_code_cache_version_apply
(
node
))
version
.
append
(
node
.
op
.
c_code_cache_version_apply
(
node
))
except
AttributeError
:
pass
for
i
in
node
.
inputs
:
for
i
in
node
.
inputs
:
version
.
append
(
i
.
type
.
c_code_cache_version
())
version
.
append
(
i
.
type
.
c_code_cache_version
())
for
o
in
node
.
outputs
:
for
o
in
node
.
outputs
:
...
...
theano/gpuarray/elemwise.py
浏览文件 @
e829ba4f
...
@@ -2885,8 +2885,8 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype):
...
@@ -2885,8 +2885,8 @@ class GpuCAReduceCPY(GpuKernelBase, HideC, CAReduceDtype):
return
code
return
code
def
c_code_cache_version
(
self
):
def
c_code_cache_version
_apply
(
self
,
node
):
return
(
2
,
self
.
GpuKernelBase_version
)
return
(
2
,
self
.
kernel_version
(
node
)
)
def
generate_kernel
(
self
,
node
,
odtype
,
redux
):
def
generate_kernel
(
self
,
node
,
odtype
,
redux
):
if
isinstance
(
self
.
scalar_op
,
scalar
.
basic
.
Add
):
if
isinstance
(
self
.
scalar_op
,
scalar
.
basic
.
Add
):
...
...
theano/scalar/basic.py
浏览文件 @
e829ba4f
...
@@ -1543,7 +1543,7 @@ xor = XOR()
...
@@ -1543,7 +1543,7 @@ xor = XOR()
class
AND
(
BinaryBitOp
):
class
AND
(
BinaryBitOp
):
identity
=
1
identity
=
-
1
commutative
=
True
commutative
=
True
associative
=
True
associative
=
True
nfunc_spec
=
(
'bitwise_and'
,
2
,
1
)
nfunc_spec
=
(
'bitwise_and'
,
2
,
1
)
...
@@ -1555,6 +1555,10 @@ class AND(BinaryBitOp):
...
@@ -1555,6 +1555,10 @@ class AND(BinaryBitOp):
(
x
,
y
)
=
inputs
(
x
,
y
)
=
inputs
(
z
,)
=
outputs
(
z
,)
=
outputs
return
"
%(z)
s = (
%(x)
s &
%(y)
s);"
%
locals
()
return
"
%(z)
s = (
%(x)
s &
%(y)
s);"
%
locals
()
def
c_code_cache_version
(
self
):
super_version
=
super
(
AND
,
self
)
.
c_code_cache_version
()
return
super_version
+
(
3
,)
and_
=
AND
()
and_
=
AND
()
...
...
theano/tensor/basic.py
浏览文件 @
e829ba4f
...
@@ -1232,7 +1232,10 @@ class MaxAndArgmax(Op):
...
@@ -1232,7 +1232,10 @@ class MaxAndArgmax(Op):
transposed_x
=
numpy
.
transpose
(
x
,
numpy
.
concatenate
((
keep_axes
,
axes
)))
transposed_x
=
numpy
.
transpose
(
x
,
numpy
.
concatenate
((
keep_axes
,
axes
)))
kept_shape
=
transposed_x
.
shape
[:
len
(
keep_axes
)]
kept_shape
=
transposed_x
.
shape
[:
len
(
keep_axes
)]
reduced_shape
=
transposed_x
.
shape
[
len
(
keep_axes
):]
reduced_shape
=
transposed_x
.
shape
[
len
(
keep_axes
):]
new_shape
=
kept_shape
+
(
numpy
.
prod
(
reduced_shape
),)
# Numpy.prod returns 1.0 when arg is empty, so we cast it to int64
# Otherwise reshape would complain citing float arg
new_shape
=
kept_shape
+
(
numpy
.
prod
(
reduced_shape
,
dtype
=
'int64'
),)
reshaped_x
=
transposed_x
.
reshape
(
new_shape
)
reshaped_x
=
transposed_x
.
reshape
(
new_shape
)
max_idx
[
0
]
=
theano
.
_asarray
(
numpy
.
argmax
(
reshaped_x
,
axis
=-
1
),
max_idx
[
0
]
=
theano
.
_asarray
(
numpy
.
argmax
(
reshaped_x
,
axis
=-
1
),
...
...
theano/tensor/elemwise.py
浏览文件 @
e829ba4f
...
@@ -21,6 +21,9 @@ from theano.misc.frozendict import frozendict
...
@@ -21,6 +21,9 @@ from theano.misc.frozendict import frozendict
config
=
theano
.
config
config
=
theano
.
config
_numpy_ver
=
[
int
(
n
)
for
n
in
numpy
.
__version__
.
split
(
'.'
)[:
2
]]
# tensor depends on elemwise to provide definitions for several ops
# tensor depends on elemwise to provide definitions for several ops
# but elemwise needs to make TensorType instances, so we have these as
# but elemwise needs to make TensorType instances, so we have these as
# placeholders and the tensor module fills them
# placeholders and the tensor module fills them
...
@@ -1315,7 +1318,12 @@ class CAReduce(Op):
...
@@ -1315,7 +1318,12 @@ class CAReduce(Op):
self
.
ufunc
=
numpy
.
maximum
self
.
ufunc
=
numpy
.
maximum
elif
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
Minimum
):
elif
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
Minimum
):
self
.
ufunc
=
numpy
.
minimum
self
.
ufunc
=
numpy
.
minimum
elif
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
AND
):
elif
(
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
AND
)
and
_numpy_ver
>=
[
1
,
12
]):
# numpy.bitwise_and.identity was incorrect for versions before
# 1.12 (it was 1 instead of -1), so we skip it in that case.
# We will fall back to the "else:" case, which defines a
# ufunc without identity.
self
.
ufunc
=
numpy
.
bitwise_and
self
.
ufunc
=
numpy
.
bitwise_and
elif
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
OR
):
elif
isinstance
(
scalar_op
,
theano
.
scalar
.
basic
.
OR
):
self
.
ufunc
=
numpy
.
bitwise_or
self
.
ufunc
=
numpy
.
bitwise_or
...
@@ -1615,7 +1623,8 @@ for(int i=0;i<PyArray_NDIM(%(iname)s);i++){
...
@@ -1615,7 +1623,8 @@ for(int i=0;i<PyArray_NDIM(%(iname)s);i++){
return
[
'<vector>'
,
'<algorithm>'
]
return
[
'<vector>'
,
'<algorithm>'
]
def
c_code_cache_version_apply
(
self
,
node
):
def
c_code_cache_version_apply
(
self
,
node
):
version
=
(
6
,)
# the version corresponding to the c code in this Op
# the version corresponding to the c code in this Op
version
=
[
6
]
# now we insert versions for the ops on which we depend...
# now we insert versions for the ops on which we depend...
scalar_node
=
Apply
(
scalar_node
=
Apply
(
...
...
theano/tensor/tests/test_elemwise.py
浏览文件 @
e829ba4f
...
@@ -330,6 +330,22 @@ class test_Broadcast(unittest.TestCase):
...
@@ -330,6 +330,22 @@ class test_Broadcast(unittest.TestCase):
assert
(
f
(
xv
)
==
zv
)
.
all
()
assert
(
f
(
xv
)
==
zv
)
.
all
()
def
reduce_bitwise_and
(
x
,
axis
=-
1
,
dtype
=
'int8'
):
identity
=
numpy
.
array
((
-
1
,),
dtype
=
dtype
)[
0
]
shape_without_axis
=
tuple
([
s
for
i
,
s
in
enumerate
(
x
.
shape
)
if
i
!=
axis
])
if
0
in
shape_without_axis
:
return
numpy
.
empty
(
shape
=
shape_without_axis
,
dtype
=
x
.
dtype
)
def
custom_reduce
(
a
):
out
=
identity
for
i
in
range
(
a
.
size
):
out
=
numpy
.
bitwise_and
(
a
[
i
],
out
)
return
out
return
numpy
.
apply_along_axis
(
custom_reduce
,
axis
,
x
)
class
test_CAReduce
(
unittest_tools
.
InferShapeTester
):
class
test_CAReduce
(
unittest_tools
.
InferShapeTester
):
op
=
CAReduce
op
=
CAReduce
cases
=
[((
5
,
6
),
None
),
cases
=
[((
5
,
6
),
None
),
...
@@ -430,7 +446,7 @@ class test_CAReduce(unittest_tools.InferShapeTester):
...
@@ -430,7 +446,7 @@ class test_CAReduce(unittest_tools.InferShapeTester):
zv
=
numpy
.
bitwise_or
.
reduce
(
zv
,
axis
)
zv
=
numpy
.
bitwise_or
.
reduce
(
zv
,
axis
)
elif
scalar_op
==
scalar
.
and_
:
elif
scalar_op
==
scalar
.
and_
:
for
axis
in
reversed
(
sorted
(
tosum
)):
for
axis
in
reversed
(
sorted
(
tosum
)):
zv
=
numpy
.
bitwise_and
.
reduce
(
zv
,
axis
)
zv
=
reduce_bitwise_and
(
zv
,
axis
,
dtype
=
dtype
)
elif
scalar_op
==
scalar
.
xor
:
elif
scalar_op
==
scalar
.
xor
:
# There is no identity value for the xor function
# There is no identity value for the xor function
# So we can't support shape of dimensions 0.
# So we can't support shape of dimensions 0.
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论