Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fa6a8eb4
提交
fa6a8eb4
authored
2月 10, 2016
作者:
Samira Shabanian
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
set kmap to be None
上级
91fe71d9
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
11 行删除
+11
-11
basic.py
theano/sparse/basic.py
+11
-11
没有找到文件。
theano/sparse/basic.py
浏览文件 @
fa6a8eb4
...
@@ -554,7 +554,7 @@ class CSMProperties(gof.Op):
...
@@ -554,7 +554,7 @@ class CSMProperties(gof.Op):
if
self
.
kmap
is
None
:
if
self
.
kmap
is
None
:
out
[
0
][
0
]
=
csm
.
data
out
[
0
][
0
]
=
csm
.
data
else
:
else
:
out
[
0
][
0
]
=
csm
.
data
[
self
.
kmap
]
warnings
.
warn
(
"Do not use kmap, it is removed"
)
if
str
(
csm
.
data
.
dtype
)
==
'int32'
:
if
str
(
csm
.
data
.
dtype
)
==
'int32'
:
out
[
0
][
0
]
=
theano
.
_asarray
(
out
[
0
][
0
],
dtype
=
'int32'
)
out
[
0
][
0
]
=
theano
.
_asarray
(
out
[
0
][
0
],
dtype
=
'int32'
)
# backport
# backport
...
@@ -659,8 +659,9 @@ class CSM(gof.Op):
...
@@ -659,8 +659,9 @@ class CSM(gof.Op):
# for efficiency, if remap does nothing, then do not apply it
# for efficiency, if remap does nothing, then do not apply it
if
kmap
is
not
None
and
all
(
kmap
==
numpy
.
arange
(
numpy
.
size
(
kmap
))):
if
kmap
is
not
None
and
all
(
kmap
==
numpy
.
arange
(
numpy
.
size
(
kmap
))):
kmap
=
None
kmap
=
None
self
.
kmap
=
kmap
self
.
kmap
=
kmap
if
self
.
kmap
is
not
None
:
warnings
.
warn
(
"Do not use kmap, it is removed"
)
if
not
isinstance
(
self
.
kmap
,
numpy
.
ndarray
):
if
not
isinstance
(
self
.
kmap
,
numpy
.
ndarray
):
# should view the other inputs too, but viewing multiple
# should view the other inputs too, but viewing multiple
...
@@ -679,7 +680,7 @@ class CSM(gof.Op):
...
@@ -679,7 +680,7 @@ class CSM(gof.Op):
def
__str__
(
self
):
def
__str__
(
self
):
if
self
.
kmap
is
not
None
:
if
self
.
kmap
is
not
None
:
return
"
%
s{
%
s}"
%
(
self
.
__class__
.
__name__
,
str
(
self
.
kmap
)
)
warnings
.
warn
(
"Do not use kmap, it is removed"
)
return
self
.
__class__
.
__name__
return
self
.
__class__
.
__name__
def
make_node
(
self
,
data
,
indices
,
indptr
,
shape
):
def
make_node
(
self
,
data
,
indices
,
indptr
,
shape
):
...
@@ -727,7 +728,7 @@ class CSM(gof.Op):
...
@@ -727,7 +728,7 @@ class CSM(gof.Op):
(
data
,
indices
,
indptr
,
shape
)
=
inputs
(
data
,
indices
,
indptr
,
shape
)
=
inputs
(
out
,)
=
outputs
(
out
,)
=
outputs
if
self
.
kmap
is
not
None
:
if
self
.
kmap
is
not
None
:
data
=
data
[
self
.
kmap
]
warnings
.
warn
(
"Do not use kmap, it is removed"
)
if
len
(
shape
)
!=
2
:
if
len
(
shape
)
!=
2
:
raise
ValueError
(
'Shape should be an array of length 2'
)
raise
ValueError
(
'Shape should be an array of length 2'
)
...
@@ -766,8 +767,7 @@ class CSM(gof.Op):
...
@@ -766,8 +767,7 @@ class CSM(gof.Op):
# node.inputs[3] is of lenght as we only support sparse matrix.
# node.inputs[3] is of lenght as we only support sparse matrix.
return
[(
node
.
inputs
[
3
][
0
],
node
.
inputs
[
3
][
1
])]
return
[(
node
.
inputs
[
3
][
0
],
node
.
inputs
[
3
][
1
])]
else
:
else
:
raise
theano
.
tensor
.
basic
.
ShapeError
(
"case not implemented"
)
raise
Exception
(
"Do not use kmap, it is removed"
)
CSC
=
CSM
(
'csc'
)
CSC
=
CSM
(
'csc'
)
"""
"""
...
@@ -846,7 +846,10 @@ class CSMGrad(gof.op.Op):
...
@@ -846,7 +846,10 @@ class CSMGrad(gof.op.Op):
# gradient data vector.
# gradient data vector.
def
__init__
(
self
,
kmap
=
None
):
def
__init__
(
self
,
kmap
=
None
):
if
kmap
==
None
:
self
.
kmap
=
kmap
self
.
kmap
=
kmap
else
:
warnings
.
warn
(
"Do not use kmap, it is removed"
)
# This class always allocate a new output.
# This class always allocate a new output.
# I keep this here to help GD understand what this kmap think is.
# I keep this here to help GD understand what this kmap think is.
# if self.kmap is None:
# if self.kmap is None:
...
@@ -893,16 +896,13 @@ class CSMGrad(gof.op.Op):
...
@@ -893,16 +896,13 @@ class CSMGrad(gof.op.Op):
if
self
.
kmap
is
None
:
if
self
.
kmap
is
None
:
g_out
[
0
]
=
gout_data
g_out
[
0
]
=
gout_data
else
:
grad
=
numpy
.
zeros_like
(
x_data
)
grad
[
self
.
kmap
]
=
gout_data
g_out
[
0
]
=
grad
def
infer_shape
(
self
,
node
,
shapes
):
def
infer_shape
(
self
,
node
,
shapes
):
if
self
.
kmap
is
None
:
if
self
.
kmap
is
None
:
return
[
shapes
[
1
]]
return
[
shapes
[
1
]]
else
:
else
:
return
[
shapes
[
0
]]
raise
Exception
(
"Do not use kmap, it is removed"
)
csm_grad
=
CSMGrad
csm_grad
=
CSMGrad
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论