Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
fa35dffc
提交
fa35dffc
authored
4月 11, 2008
作者:
bergstrj@iro.umontreal.ca
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fixed grad signatures in tensor.py
上级
0976892d
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
9 行增加
和
8 行删除
+9
-8
_test_sparse.py
_test_sparse.py
+3
-0
tensor.py
tensor.py
+6
-8
没有找到文件。
_test_sparse.py
浏览文件 @
fa35dffc
...
@@ -90,6 +90,9 @@ class _testCase_dot(unittest.TestCase):
...
@@ -90,6 +90,9 @@ class _testCase_dot(unittest.TestCase):
self
.
failUnless
(
z
.
shape
==
(
5
,
2
))
self
.
failUnless
(
z
.
shape
==
(
5
,
2
))
self
.
failUnless
(
type
(
z
)
is
mtype
)
self
.
failUnless
(
type
(
z
)
is
mtype
)
def
test_missing
(
self
):
raise
NotImplementedError
(
'tests commented out'
)
# def test_basic1(self):
# def test_basic1(self):
# """dot: sparse left"""
# """dot: sparse left"""
# a = numpy.asarray([[1, 0, 3, 0, 5], [0, 0, -2, 0, 0]],
# a = numpy.asarray([[1, 0, 3, 0, 5], [0, 0, -2, 0, 0]],
...
...
tensor.py
浏览文件 @
fa35dffc
...
@@ -173,6 +173,7 @@ def broadcast(scalar_opclass, name, inplace_versions = True):
...
@@ -173,6 +173,7 @@ def broadcast(scalar_opclass, name, inplace_versions = True):
return
C
,
c
return
C
,
c
class
Argmax
(
Op
):
class
Argmax
(
Op
):
"""Calculate the max and argmax over a given axis"""
nin
=
2
# tensor, axis
nin
=
2
# tensor, axis
nout
=
2
# max val, max idx
nout
=
2
# max val, max idx
E_axis
=
'invalid axis'
E_axis
=
'invalid axis'
...
@@ -238,8 +239,8 @@ class TransposeInplace(_Op, Viewer):
...
@@ -238,8 +239,8 @@ class TransposeInplace(_Op, Viewer):
return
[
rval
]
return
[
rval
]
def
impl
(
self
,
x
):
def
impl
(
self
,
x
):
return
x
.
T
#numpy's transpose
return
x
.
T
#numpy's transpose
def
grad
(
self
,
x
,
gz
):
def
grad
(
self
,
(
x
,),
(
gz
),
):
return
transpose
(
gz
)
return
transpose
(
gz
)
,
def
c_code
(
self
,
(
x
,
),
(
z
,
),
sub
):
def
c_code
(
self
,
(
x
,
),
(
z
,
),
sub
):
return
"""
return
"""
...
@@ -306,7 +307,7 @@ class Subtensor(Op, Viewer):
...
@@ -306,7 +307,7 @@ class Subtensor(Op, Viewer):
self
.
outputs
[
0
]
.
data
=
x
.
__getitem__
(
c
[
0
])
self
.
outputs
[
0
]
.
data
=
x
.
__getitem__
(
c
[
0
])
else
:
else
:
self
.
outputs
[
0
]
.
data
=
x
.
__getitem__
(
c
)
self
.
outputs
[
0
]
.
data
=
x
.
__getitem__
(
c
)
def
grad
(
x
,
gz
):
def
grad
(
self
,
(
x
,),
(
gz
,)
):
# - option: allocate a potentially large matrix of zeros, and fill in
# - option: allocate a potentially large matrix of zeros, and fill in
# the appropriate elements from gz
# the appropriate elements from gz
# - option: return a sparse matrix
# - option: return a sparse matrix
...
@@ -350,10 +351,7 @@ class Dot(_Op):
...
@@ -350,10 +351,7 @@ class Dot(_Op):
return
[
self
.
broadcastable_rule
(
bx
,
by
)]
return
[
self
.
broadcastable_rule
(
bx
,
by
)]
def
impl
(
self
,
x
,
y
):
def
impl
(
self
,
x
,
y
):
return
numpy
.
dot
(
x
,
y
)
return
numpy
.
dot
(
x
,
y
)
def
grad
(
self
,
(
x
,
y
),
gz
):
def
grad
(
self
,
(
x
,
y
),
(
gz
,)):
"""
@todo Shouldn't it be (gz,) ? -jpt
"""
return
dot
(
gz
,
y
.
T
),
dot
(
x
.
T
,
gz
)
return
dot
(
gz
,
y
.
T
),
dot
(
x
.
T
,
gz
)
if
0
:
if
0
:
def
c_support_code
(
self
):
def
c_support_code
(
self
):
...
@@ -414,7 +412,7 @@ class Gemm(_Op):
...
@@ -414,7 +412,7 @@ class Gemm(_Op):
z
*=
b
z
*=
b
z
+=
a
*
numpy
.
dot
(
x
,
y
)
z
+=
a
*
numpy
.
dot
(
x
,
y
)
return
z
return
z
def
grad
(
self
,
(
z
,
a
,
x
,
y
,
b
),
gz
):
def
grad
(
self
,
(
z
,
a
,
x
,
y
,
b
),
(
gz
,)
):
raise
NotImplementedError
()
raise
NotImplementedError
()
def
c_support_code
(
self
):
def
c_support_code
(
self
):
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论