Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
416e7060
提交
416e7060
authored
1月 28, 2013
作者:
Rami Al-Rfou'
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4 from viveksck/TheanoBugFix
Lazy import of sparse module and rename sparsegrad according to python coding style.
上级
2eb3a2c0
867b6489
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
11 行增加
和
5 行删除
+11
-5
basic.py
theano/tensor/basic.py
+11
-5
没有找到文件。
theano/tensor/basic.py
浏览文件 @
416e7060
...
@@ -49,6 +49,9 @@ continuous_dtypes = map(str, scal.continuous_types)
...
@@ -49,6 +49,9 @@ continuous_dtypes = map(str, scal.continuous_types)
discrete_dtypes
=
map
(
str
,
scal
.
discrete_types
)
discrete_dtypes
=
map
(
str
,
scal
.
discrete_types
)
all_dtypes
=
map
(
str
,
scal
.
all_types
)
all_dtypes
=
map
(
str
,
scal
.
all_types
)
# Do a lazy import of the sparse module
sparse_module_ref
=
None
class
ShapeError
(
Exception
):
class
ShapeError
(
Exception
):
"""Raised when the shape cannot be computed."""
"""Raised when the shape cannot be computed."""
...
@@ -619,7 +622,7 @@ class TensorType(Type):
...
@@ -619,7 +622,7 @@ class TensorType(Type):
Inf entries. (Used in `DebugMode`)
Inf entries. (Used in `DebugMode`)
"""
"""
def
__init__
(
self
,
dtype
,
broadcastable
,
name
=
None
,
sparsegrad
=
False
):
def
__init__
(
self
,
dtype
,
broadcastable
,
name
=
None
,
sparse
_
grad
=
False
):
"""Initialize self.dtype and self.broadcastable.
"""Initialize self.dtype and self.broadcastable.
:Parameters:
:Parameters:
...
@@ -644,7 +647,7 @@ class TensorType(Type):
...
@@ -644,7 +647,7 @@ class TensorType(Type):
self
.
dtype_specs
()
# error checking is done there
self
.
dtype_specs
()
# error checking is done there
self
.
name
=
name
self
.
name
=
name
self
.
numpy_dtype
=
numpy
.
dtype
(
self
.
dtype
)
self
.
numpy_dtype
=
numpy
.
dtype
(
self
.
dtype
)
self
.
sparse
grad
=
sparse
grad
self
.
sparse
_grad
=
sparse_
grad
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
def
filter
(
self
,
data
,
strict
=
False
,
allow_downcast
=
None
):
"""Convert `data` to something which can be associated to a
"""Convert `data` to something which can be associated to a
...
@@ -6521,11 +6524,14 @@ class AdvancedSubtensor1(Op):
...
@@ -6521,11 +6524,14 @@ class AdvancedSubtensor1(Op):
return
rval
return
rval
def
grad
(
self
,
inputs
,
grads
):
def
grad
(
self
,
inputs
,
grads
):
global
sparse_module_ref
gz
,
=
grads
gz
,
=
grads
assert
len
(
inputs
)
==
2
assert
len
(
inputs
)
==
2
if
inputs
[
0
]
.
type
.
sparsegrad
:
if
inputs
[
0
]
.
type
.
sparse_grad
:
rval1
=
[
theano
.
sparse
.
ConstructSparseFromList
()((
inputs
[
0
]),
gz
,
inputs
[
1
])]
if
sparse_module_ref
is
None
:
import
theano.sparse
as
sparse_module_ref
rval1
=
[
sparse_module_ref
.
ConstructSparseFromList
()((
inputs
[
0
]),
gz
,
inputs
[
1
])]
else
:
else
:
rval1
=
[
advanced_inc_subtensor1
(
zeros_like
(
inputs
[
0
]),
gz
,
inputs
[
1
])]
rval1
=
[
advanced_inc_subtensor1
(
zeros_like
(
inputs
[
0
]),
gz
,
inputs
[
1
])]
return
rval1
+
[
DisconnectedType
()()]
*
(
len
(
inputs
)
-
1
)
return
rval1
+
[
DisconnectedType
()()]
*
(
len
(
inputs
)
-
1
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论