Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f1e4ec47
Unverified
提交
f1e4ec47
authored
4月 07, 2020
作者:
Frédéric Bastien
提交者:
GitHub
4月 07, 2020
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #6749 from rebecca-palmer/numpy117scipy13
MAINT: Be compatible with numpy 1.17 and scipy 1.3
上级
10f6e349
4590439d
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
52 行增加
和
15 行删除
+52
-15
basic.txt
doc/library/tensor/basic.txt
+4
-1
test_compute_test_value.py
theano/gof/tests/test_compute_test_value.py
+5
-4
test_basic.py
theano/sparse/tests/test_basic.py
+9
-1
sort.py
theano/tensor/sort.py
+8
-0
test_basic.py
theano/tensor/tests/test_basic.py
+13
-5
test_raw_random.py
theano/tensor/tests/test_raw_random.py
+2
-2
test_shared_randomstreams.py
theano/tensor/tests/test_shared_randomstreams.py
+2
-2
var.py
theano/tensor/var.py
+9
-0
没有找到文件。
doc/library/tensor/basic.txt
浏览文件 @
f1e4ec47
...
@@ -552,7 +552,7 @@ TensorVariable
...
@@ -552,7 +552,7 @@ TensorVariable
.. method:: nonzero_values(self)
.. method:: nonzero_values(self)
.. method:: sort(self, axis=-1, kind='quicksort', order=None)
.. method:: sort(self, axis=-1, kind='quicksort', order=None)
.. method:: argsort(self, axis=-1, kind='quicksort', order=None)
.. method:: argsort(self, axis=-1, kind='quicksort', order=None)
.. method:: clip(self, a_min, a_max)
.. method:: clip(self, a_min, a_max)
with a_min <= a_max
.. method:: conf()
.. method:: conf()
.. method:: repeat(repeats, axis=None)
.. method:: repeat(repeats, axis=None)
.. method:: round(mode="half_away_from_zero")
.. method:: round(mode="half_away_from_zero")
...
@@ -1350,6 +1350,9 @@ Condition
...
@@ -1350,6 +1350,9 @@ Condition
Normal broadcasting rules apply to each of `x`, `min`, and `max`.
Normal broadcasting rules apply to each of `x`, `min`, and `max`.
Note that there is no warning for inputs that are the wrong way round
(`min > max`), and that results in this case may differ from ``numpy.clip``.
Bit-wise
Bit-wise
--------
--------
...
...
theano/gof/tests/test_compute_test_value.py
浏览文件 @
f1e4ec47
...
@@ -285,12 +285,13 @@ class TestComputeTestValue(unittest.TestCase):
...
@@ -285,12 +285,13 @@ class TestComputeTestValue(unittest.TestCase):
except
ValueError
:
except
ValueError
:
# Get traceback
# Get traceback
tb
=
sys
.
exc_info
()[
2
]
tb
=
sys
.
exc_info
()[
2
]
# Get frame info 4 layers up
frame_infos
=
traceback
.
extract_tb
(
tb
)
frame_info
=
traceback
.
extract_tb
(
tb
)[
-
5
]
# We should be in the "fx" function defined above
# We should be in the "fx" function defined above
expected
=
'test_compute_test_value.py'
expected
=
'test_compute_test_value.py'
assert
os
.
path
.
split
(
frame_info
[
0
])[
1
]
==
expected
,
frame_info
assert
any
((
os
.
path
.
split
(
assert
frame_info
[
2
]
==
'fx'
frame_info
[
0
])[
1
]
==
expected
and
frame_info
[
2
]
==
'fx'
)
for
frame_info
in
frame_infos
),
frame_infos
finally
:
finally
:
theano
.
config
.
compute_test_value
=
orig_compute_test_value
theano
.
config
.
compute_test_value
=
orig_compute_test_value
...
...
theano/sparse/tests/test_basic.py
浏览文件 @
f1e4ec47
...
@@ -160,7 +160,15 @@ def sparse_random_inputs(format, shape, n=1, out_dtype=None, p=0.5, gap=None,
...
@@ -160,7 +160,15 @@ def sparse_random_inputs(format, shape, n=1, out_dtype=None, p=0.5, gap=None,
if
unsorted_indices
:
if
unsorted_indices
:
for
idx
in
range
(
n
):
for
idx
in
range
(
n
):
d
=
data
[
idx
]
d
=
data
[
idx
]
d
=
d
[
list
(
range
(
d
.
shape
[
0
]))]
# these flip the matrix, but it's random anyway
if
format
==
'csr'
:
d
=
scipy
.
sparse
.
csr_matrix
(
(
d
.
data
,
d
.
shape
[
1
]
-
1
-
d
.
indices
,
d
.
indptr
),
shape
=
d
.
shape
)
if
format
==
'csc'
:
d
=
scipy
.
sparse
.
csc_matrix
(
(
d
.
data
,
d
.
shape
[
0
]
-
1
-
d
.
indices
,
d
.
indptr
),
shape
=
d
.
shape
)
assert
not
d
.
has_sorted_indices
assert
not
d
.
has_sorted_indices
data
[
idx
]
=
d
data
[
idx
]
=
d
if
explicit_zero
:
if
explicit_zero
:
...
...
theano/tensor/sort.py
浏览文件 @
f1e4ec47
...
@@ -45,6 +45,10 @@ class SortOp(theano.Op):
...
@@ -45,6 +45,10 @@ class SortOp(theano.Op):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
a
=
inputs
[
0
]
a
=
inputs
[
0
]
axis
=
inputs
[
1
]
axis
=
inputs
[
1
]
if
axis
is
not
None
:
if
axis
!=
int
(
axis
):
raise
ValueError
(
"sort axis must be an integer or None"
)
axis
=
int
(
axis
)
z
=
output_storage
[
0
]
z
=
output_storage
[
0
]
z
[
0
]
=
np
.
sort
(
a
,
axis
,
self
.
kind
,
self
.
order
)
z
[
0
]
=
np
.
sort
(
a
,
axis
,
self
.
kind
,
self
.
order
)
...
@@ -172,6 +176,10 @@ class ArgSortOp(theano.Op):
...
@@ -172,6 +176,10 @@ class ArgSortOp(theano.Op):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
def
perform
(
self
,
node
,
inputs
,
output_storage
):
a
=
inputs
[
0
]
a
=
inputs
[
0
]
axis
=
inputs
[
1
]
axis
=
inputs
[
1
]
if
axis
is
not
None
:
if
axis
!=
int
(
axis
):
raise
ValueError
(
"sort axis must be an integer or None"
)
axis
=
int
(
axis
)
z
=
output_storage
[
0
]
z
=
output_storage
[
0
]
z
[
0
]
=
theano
.
_asarray
(
np
.
argsort
(
a
,
axis
,
self
.
kind
,
self
.
order
),
z
[
0
]
=
theano
.
_asarray
(
np
.
argsort
(
a
,
axis
,
self
.
kind
,
self
.
order
),
dtype
=
node
.
outputs
[
0
]
.
dtype
)
dtype
=
node
.
outputs
[
0
]
.
dtype
)
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
f1e4ec47
...
@@ -2835,11 +2835,7 @@ ClipTester = makeTester(
...
@@ -2835,11 +2835,7 @@ ClipTester = makeTester(
correct6
=
(
randint
(
5
,
5
)
.
astype
(
'int64'
),
correct6
=
(
randint
(
5
,
5
)
.
astype
(
'int64'
),
np
.
array
(
-
1
,
dtype
=
'int64'
),
np
.
array
(
-
1
,
dtype
=
'int64'
),
np
.
array
(
1
,
dtype
=
'int64'
)),
np
.
array
(
1
,
dtype
=
'int64'
)),
# min > max. messed up behaviour, but
# min > max case moved below as numpy has changed
# should be same as NumPy's
correct7
=
((
5
*
rand
(
5
,
5
))
.
astype
(
'float64'
),
np
.
array
(
1
,
dtype
=
'float64'
),
np
.
array
(
-
1
,
dtype
=
'float64'
)),
correct8
=
(
randint
(
0
,
5
)
.
astype
(
'uint8'
),
correct8
=
(
randint
(
0
,
5
)
.
astype
(
'uint8'
),
np
.
array
(
2
,
dtype
=
'uint8'
),
np
.
array
(
2
,
dtype
=
'uint8'
),
np
.
array
(
4
,
dtype
=
'uint8'
)),
np
.
array
(
4
,
dtype
=
'uint8'
)),
...
@@ -2850,6 +2846,18 @@ ClipTester = makeTester(
...
@@ -2850,6 +2846,18 @@ ClipTester = makeTester(
)
)
# min > max case - numpy.clip has changed but we haven't
# https://github.com/Theano/Theano/issues/6715
BackwardsClipTester
=
makeTester
(
name
=
'BackwardsClipTester'
,
op
=
clip
,
expected
=
lambda
x
,
y
,
z
:
np
.
where
(
x
<
y
,
y
,
np
.
minimum
(
x
,
z
)),
good
=
dict
(
correct7
=
((
5
*
rand
(
5
,
5
))
.
astype
(
'float64'
),
np
.
array
(
1
,
dtype
=
'float64'
),
np
.
array
(
-
1
,
dtype
=
'float64'
)),)
)
class
T_Clip
(
unittest
.
TestCase
):
class
T_Clip
(
unittest
.
TestCase
):
def
test_complex_value
(
self
):
def
test_complex_value
(
self
):
for
dtype
in
[
'complex64'
,
'complex128'
]:
for
dtype
in
[
'complex64'
,
'complex128'
]:
...
...
theano/tensor/tests/test_raw_random.py
浏览文件 @
f1e4ec47
...
@@ -678,10 +678,10 @@ class T_random_function(utt.InferShapeTester):
...
@@ -678,10 +678,10 @@ class T_random_function(utt.InferShapeTester):
numpy_val1c
=
as_floatX
(
numpy_rng
.
uniform
(
low
=
[
-
4.
],
high
=
[
-
1
]))
numpy_val1c
=
as_floatX
(
numpy_rng
.
uniform
(
low
=
[
-
4.
],
high
=
[
-
1
]))
assert
np
.
all
(
val0c
==
numpy_val0c
)
assert
np
.
all
(
val0c
==
numpy_val0c
)
assert
np
.
all
(
val1c
==
numpy_val1c
)
assert
np
.
all
(
val1c
==
numpy_val1c
)
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
])
#
self.assertRaises(ValueError, fc, post1c, [-4., -2], [-1, 0], [1])
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
,
2
])
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
,
2
])
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
2
,
1
])
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
2
,
1
])
self
.
assertRaises
(
ValueError
,
fc
,
post1c
,
[
-
4.
,
-
2
],
[
-
1
],
[
1
])
#
self.assertRaises(ValueError, fc, post1c, [-4., -2], [-1], [1])
# TODO: do we want that?
# TODO: do we want that?
#self.assertRaises(ValueError, fc, post1c, [-4., -2], [-1], [2])
#self.assertRaises(ValueError, fc, post1c, [-4., -2], [-1], [2])
...
...
theano/tensor/tests/test_shared_randomstreams.py
浏览文件 @
f1e4ec47
...
@@ -466,10 +466,10 @@ class T_SharedRandomStreams(unittest.TestCase):
...
@@ -466,10 +466,10 @@ class T_SharedRandomStreams(unittest.TestCase):
numpy_val1c
=
numpy_rng
.
uniform
(
low
=
[
-
4.
],
high
=
[
-
1
])
numpy_val1c
=
numpy_rng
.
uniform
(
low
=
[
-
4.
],
high
=
[
-
1
])
assert
np
.
all
(
val0c
==
numpy_val0c
)
assert
np
.
all
(
val0c
==
numpy_val0c
)
assert
np
.
all
(
val1c
==
numpy_val1c
)
assert
np
.
all
(
val1c
==
numpy_val1c
)
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
])
#
self.assertRaises(ValueError, fc, [-4., -2], [-1, 0], [1])
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
,
2
])
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
1
,
2
])
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
2
,
1
])
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
,
0
],
[
2
,
1
])
self
.
assertRaises
(
ValueError
,
fc
,
[
-
4.
,
-
2
],
[
-
1
],
[
1
])
#
self.assertRaises(ValueError, fc, [-4., -2], [-1], [1])
# TODO: do we want that?
# TODO: do we want that?
#self.assertRaises(ValueError, fc, [-4., -2], [-1], [2])
#self.assertRaises(ValueError, fc, [-4., -2], [-1], [2])
...
...
theano/tensor/var.py
浏览文件 @
f1e4ec47
...
@@ -247,6 +247,15 @@ class _tensor_py_operators(object):
...
@@ -247,6 +247,15 @@ class _tensor_py_operators(object):
def
__rpow__
(
self
,
other
):
def
__rpow__
(
self
,
other
):
return
theano
.
tensor
.
basic
.
pow
(
other
,
self
)
return
theano
.
tensor
.
basic
.
pow
(
other
,
self
)
def
__ceil__
(
self
):
return
theano
.
tensor
.
ceil
(
self
)
def
__floor__
(
self
):
return
theano
.
tensor
.
floor
(
self
)
def
__trunc__
(
self
):
return
theano
.
tensor
.
trunc
(
self
)
# TRANSPOSE
# TRANSPOSE
T
=
property
(
lambda
self
:
theano
.
tensor
.
basic
.
transpose
(
self
))
T
=
property
(
lambda
self
:
theano
.
tensor
.
basic
.
transpose
(
self
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论