Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
264a74f3
提交
264a74f3
authored
11月 28, 2016
作者:
Zhouhan LIN
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
clip and minimum, change ExtractDiag names
上级
466d8929
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
21 行增加
和
22 行删除
+21
-22
subtensor.py
theano/gpuarray/subtensor.py
+4
-5
basic.py
theano/tensor/basic.py
+3
-3
test_basic.py
theano/tensor/tests/test_basic.py
+14
-14
没有找到文件。
theano/gpuarray/subtensor.py
浏览文件 @
264a74f3
...
...
@@ -8,8 +8,7 @@ from six.moves import StringIO
from
theano
import
tensor
,
gof
,
Op
from
theano.gradient
import
grad_not_implemented
import
theano.tensor.clip
import
theano.tensor.minimum
import
theano.tensor
as
T
from
theano.tensor.subtensor
import
IncSubtensor
,
Subtensor
,
get_idx_list
try
:
...
...
@@ -1177,10 +1176,10 @@ class GpuDiagonal(Subtensor):
# The following logic is inspired by C code of PyArray_Diagonal().
offset
=
self
.
offset
if
offset
>
0
:
diag_size
=
theano
.
tensor
.
clip
(
dim2
-
offset
,
0
,
dim1
)
diag_size
=
T
.
clip
(
dim2
-
offset
,
0
,
dim1
)
elif
offset
<
0
:
diag_size
=
theano
.
tensor
.
clip
(
dim1
+
offset
,
0
,
dim2
)
diag_size
=
T
.
clip
(
dim1
+
offset
,
0
,
dim2
)
else
:
diag_size
=
theano
.
tensor
.
minimum
(
dim1
,
dim2
)
diag_size
=
T
.
minimum
(
dim1
,
dim2
)
out_shape
.
append
(
diag_size
)
return
[
tuple
(
out_shape
)]
theano/tensor/basic.py
浏览文件 @
264a74f3
...
...
@@ -6045,10 +6045,10 @@ class ExtractDiag(Op):
def
__init__
(
self
,
offset
=
0
,
axis1
=
0
,
axis2
=
1
,
view
=
False
):
self
.
view
=
view
if
self
.
view
and
not
numpy_diagonal_return_view
:
warnings
.
warn
(
"View will forced to False.
Diagonal
property view is "
warnings
.
warn
(
"View will forced to False.
ExtractDiag
property view is "
"set to True but numpy version
%
s and prior versions of "
"numpy.diagonal() do not return a view. Update "
"numpy to use
Diagonal
(view=True)"
%
"numpy to use
ExtractDiag
(view=True)"
%
numpy
.
version
.
version
)
self
.
view
=
False
if
self
.
view
:
...
...
@@ -6061,7 +6061,7 @@ class ExtractDiag(Op):
x
=
as_tensor_variable
(
x
)
if
x
.
ndim
<
2
:
raise
ValueError
(
'
Diagonal
needs an input with 2 or more '
raise
ValueError
(
'
ExtractDiag
needs an input with 2 or more '
'dimensions'
,
x
)
return
Apply
(
self
,
[
x
],
[
x
.
type
.
__class__
(
dtype
=
x
.
dtype
,
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
264a74f3
...
...
@@ -45,7 +45,7 @@ from theano.tensor import (_shared, wvector, bvector,
tile
,
patternbroadcast
,
Eye
,
Shape
,
Dot
,
PermuteRowElements
,
ScalarFromTensor
,
TensorFromScalar
,
dtensor4
,
Rebroadcast
,
Alloc
,
dtensor3
,
SpecifyShape
,
Mean
,
itensor3
,
Tile
,
switch
,
Diagonal
,
Diag
,
itensor3
,
Tile
,
switch
,
ExtractDiag
,
Diag
,
nonzero
,
flatnonzero
,
nonzero_values
,
stacklists
,
DimShuffle
,
hessian
,
ptp
,
power
,
swapaxes
,
choose
,
Choose
,
NoneConst
,
AllocEmpty
,
...
...
@@ -7427,27 +7427,27 @@ class TestInferShape(utt.InferShapeTester):
[
Tri
()(
aiscal
,
biscal
,
ciscal
)],
[
3
,
5
,
0
],
Tri
)
#
Diagonal
#
ExtractDiag
atens3
=
tensor3
()
atens3_val
=
rand
(
4
,
5
,
3
)
atens3_diag
=
Diagonal
()(
atens3
)
atens3_diag
=
ExtractDiag
()(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
atens3_diag
=
Diagonal
(
1
)(
atens3
)
[
atens3_val
],
ExtractDiag
)
atens3_diag
=
ExtractDiag
(
1
)(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
atens3_diag
=
Diagonal
(
-
1
)(
atens3
)
[
atens3_val
],
ExtractDiag
)
atens3_diag
=
ExtractDiag
(
-
1
)(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
atens3_diag
=
Diagonal
(
1
,
0
,
2
)(
atens3
)
[
atens3_val
],
ExtractDiag
)
atens3_diag
=
ExtractDiag
(
1
,
0
,
2
)(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
atens3_diag
=
Diagonal
(
1
,
1
,
2
)(
atens3
)
[
atens3_val
],
ExtractDiag
)
atens3_diag
=
ExtractDiag
(
1
,
1
,
2
)(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
atens3_diag
=
Diagonal
(
1
,
2
,
0
)(
atens3
)
[
atens3_val
],
ExtractDiag
)
atens3_diag
=
ExtractDiag
(
1
,
2
,
0
)(
atens3
)
self
.
_compile_and_check
([
atens3
],
[
atens3_diag
],
[
atens3_val
],
Diagonal
)
[
atens3_val
],
ExtractDiag
)
# Diag
advec
=
dvector
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论