Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5111df45
提交
5111df45
authored
8月 31, 2010
作者:
gdesjardins
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
a81abf76
4431bc09
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
33 行增加
和
3 行删除
+33
-3
graph.py
theano/gof/graph.py
+6
-0
basic.py
theano/tensor/basic.py
+10
-0
test_basic.py
theano/tensor/tests/test_basic.py
+14
-0
test_opt.py
theano/tensor/tests/test_opt.py
+3
-3
没有找到文件。
theano/gof/graph.py
浏览文件 @
5111df45
...
@@ -364,6 +364,12 @@ class Constant(Value):
...
@@ -364,6 +364,12 @@ class Constant(Value):
if
self
.
name
is
not
None
:
if
self
.
name
is
not
None
:
return
self
.
name
return
self
.
name
return
str
(
self
.
data
)
#+ "::" + str(self.type)
return
str
(
self
.
data
)
#+ "::" + str(self.type)
def
clone
(
self
):
"""
We clone this object, but we don't clone the data to lower memory requirement
We suppose that the data will never change.
"""
return
self
.
__class__
(
self
.
type
,
self
.
data
,
self
.
name
)
...
...
theano/tensor/basic.py
浏览文件 @
5111df45
...
@@ -3712,6 +3712,11 @@ pprint.assign(dot, printing.OperatorPrinter(printing.special['middle_dot'], -1,
...
@@ -3712,6 +3712,11 @@ pprint.assign(dot, printing.OperatorPrinter(printing.special['middle_dot'], -1,
#########################
#########################
class
TensorDotGrad
(
Op
):
class
TensorDotGrad
(
Op
):
def
__init__
(
self
,
axes
):
def
__init__
(
self
,
axes
):
if
isinstance
(
axes
,
list
):
for
i
,
a
in
enumerate
(
axes
):
if
isinstance
(
a
,
list
):
axes
[
i
]
=
tuple
(
a
)
axes
=
tuple
(
axes
)
self
.
axes
=
axes
;
self
.
axes
=
axes
;
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
...
@@ -3759,6 +3764,11 @@ class TensorDot(Op):
...
@@ -3759,6 +3764,11 @@ class TensorDot(Op):
"""
"""
def
__init__
(
self
,
axes
):
def
__init__
(
self
,
axes
):
if
isinstance
(
axes
,
list
):
for
i
,
a
in
enumerate
(
axes
):
if
isinstance
(
a
,
list
):
axes
[
i
]
=
tuple
(
a
)
axes
=
tuple
(
axes
)
self
.
axes
=
axes
;
self
.
axes
=
axes
;
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
5111df45
...
@@ -2444,6 +2444,20 @@ class test_tensordot(unittest.TestCase):
...
@@ -2444,6 +2444,20 @@ class test_tensordot(unittest.TestCase):
f6
(
bval
,
aval
)))
f6
(
bval
,
aval
)))
utt
.
verify_grad
(
TensorDot
(
axes
),
[
bval
,
aval
])
utt
.
verify_grad
(
TensorDot
(
axes
),
[
bval
,
aval
])
def
test_list
(
self
):
# test matrix-matrix
amat
=
dmatrix
()
bmat
=
dmatrix
()
axes
=
[[
1
,],[
0
,]]
c
=
tensordot
(
axes
)(
amat
,
bmat
)
f3
=
inplace_func
([
amat
,
bmat
],
c
)
aval
=
numpy
.
random
.
rand
(
4
,
7
);
bval
=
numpy
.
random
.
rand
(
7
,
9
);
self
.
failUnless
(
numpy
.
all
(
numpy
.
tensordot
(
aval
,
bval
,
axes
)
==
\
f3
(
aval
,
bval
)))
utt
.
verify_grad
(
TensorDot
(
axes
),
[
aval
,
bval
])
def
test_smallest_stack
():
def
test_smallest_stack
():
sx
,
sy
=
dscalar
(),
dscalar
()
sx
,
sy
=
dscalar
(),
dscalar
()
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
5111df45
...
@@ -1015,15 +1015,15 @@ def test_log1p():
...
@@ -1015,15 +1015,15 @@ def test_log1p():
# the first three ops are Shape_i, Shape_i, and Dimshuffle
# the first three ops are Shape_i, Shape_i, and Dimshuffle
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
==
[
inplace
.
log1p_inplace
,
alloc
]
==
[
T
.
log1p
,
alloc
]
f
=
function
([
x
,
y
],
T
.
log
(
0
+
(
x
)
+
fill
(
y
,
1.0
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
0
+
(
x
)
+
fill
(
y
,
1.0
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
==
[
inplace
.
log1p_inplace
,
alloc
]
==
[
T
.
log1p
,
alloc
]
f
=
function
([
x
,
y
],
T
.
log
(
2
+
(
x
)
-
fill
(
y
,
1.0
)),
mode
=
m
)
f
=
function
([
x
,
y
],
T
.
log
(
2
+
(
x
)
-
fill
(
y
,
1.0
)),
mode
=
m
)
theano
.
printing
.
debugprint
(
f
)
theano
.
printing
.
debugprint
(
f
)
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
assert
[
node
.
op
for
node
in
f
.
maker
.
env
.
toposort
()][
3
:]
\
==
[
inplace
.
log1p_inplace
,
alloc
]
==
[
T
.
log1p
,
alloc
]
f
([
1e-7
,
10
],
[[
0
,
0
],
[
0
,
0
]])
#debugmode will verify values
f
([
1e-7
,
10
],
[[
0
,
0
],
[
0
,
0
]])
#debugmode will verify values
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论