Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f3afab87
提交
f3afab87
authored
3月 15, 2012
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
More pep8 / pyflakes
上级
034bb5a3
全部展开
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
15 行增加
和
12 行删除
+15
-12
builders.py
theano/compile/builders.py
+15
-12
test_debugmode.py
theano/compile/tests/test_debugmode.py
+0
-0
test_blas.py
theano/sandbox/cuda/tests/test_blas.py
+0
-0
elemwise.py
theano/tensor/elemwise.py
+0
-0
没有找到文件。
theano/compile/builders.py
浏览文件 @
f3afab87
from
theano
import
gof
from
theano
import
gof
from
theano
import
gradient
as
G
from
theano
import
gradient
as
G
from
function_module
import
orig_function
from
function_module
import
orig_function
...
@@ -33,16 +32,19 @@ class OpFromGraph(gof.Op):
...
@@ -33,16 +32,19 @@ class OpFromGraph(gof.Op):
e2 = op(x, y, z) + op(z, y, x)
e2 = op(x, y, z) + op(z, y, x)
fn = function([x, y, z], [e2])
fn = function([x, y, z], [e2])
"""
"""
def
__init__
(
self
,
inputs
,
outputs
,
grad_depth
=
1
,
**
kwargs
):
def
__init__
(
self
,
inputs
,
outputs
,
grad_depth
=
1
,
**
kwargs
):
if
not
isinstance
(
outputs
,
list
):
if
not
isinstance
(
outputs
,
list
):
raise
TypeError
(
'outputs must be list'
,
outputs
)
raise
TypeError
(
'outputs must be list'
,
outputs
)
for
i
in
inputs
+
outputs
:
for
i
in
inputs
+
outputs
:
if
not
isinstance
(
i
,
gof
.
Variable
):
if
not
isinstance
(
i
,
gof
.
Variable
):
raise
TypeError
(
'inputs and outputs must be Variable instances'
,
i
)
raise
TypeError
(
'inputs and outputs must be Variable instances'
,
i
)
if
'updates'
in
kwargs
:
if
'updates'
in
kwargs
:
raise
TypeError
(
'updates are not allowed in kwargs'
)
raise
TypeError
(
'updates are not allowed in kwargs'
)
# TODO: the graph may have implicit inputs like Value and SharedVariable instances.
# TODO: the graph may have implicit inputs like Value and
# SharedVariable instances.
# what impact to they have on the validity of this Op?
# what impact to they have on the validity of this Op?
self
.
fn
=
orig_function
(
inputs
,
outputs
,
**
kwargs
)
self
.
fn
=
orig_function
(
inputs
,
outputs
,
**
kwargs
)
self
.
inputs
=
inputs
self
.
inputs
=
inputs
...
@@ -52,7 +54,8 @@ class OpFromGraph(gof.Op):
...
@@ -52,7 +54,8 @@ class OpFromGraph(gof.Op):
if
grad_depth
>
0
:
if
grad_depth
>
0
:
output_grads
=
[
t
()
for
t
in
self
.
output_types
]
output_grads
=
[
t
()
for
t
in
self
.
output_types
]
gd
=
G
.
grad_sources_inputs
(
zip
(
self
.
outputs
,
output_grads
),
self
.
inputs
)
gd
=
G
.
grad_sources_inputs
(
zip
(
self
.
outputs
,
output_grads
),
self
.
inputs
)
gs
=
map
(
gd
.
get
,
self
.
inputs
)
gs
=
map
(
gd
.
get
,
self
.
inputs
)
self
.
grad_ops
=
[]
self
.
grad_ops
=
[]
for
g
in
gs
:
for
g
in
gs
:
...
@@ -63,8 +66,9 @@ class OpFromGraph(gof.Op):
...
@@ -63,8 +66,9 @@ class OpFromGraph(gof.Op):
# to compute the gradient, so we ignore them.
# to compute the gradient, so we ignore them.
self
.
grad_ops
.
append
(
OpFromGraph
(
inputs
+
output_grads
,
self
.
grad_ops
.
append
(
OpFromGraph
(
inputs
+
output_grads
,
[
g
],
[
g
],
grad_depth
=
grad_depth
-
1
,
grad_depth
=
grad_depth
-
1
,
on_unused_input
=
'ignore'
))
on_unused_input
=
'ignore'
))
def
__eq__
(
self
,
other
):
def
__eq__
(
self
,
other
):
#TODO: recognize a copy
#TODO: recognize a copy
return
self
is
other
return
self
is
other
...
@@ -76,7 +80,8 @@ class OpFromGraph(gof.Op):
...
@@ -76,7 +80,8 @@ class OpFromGraph(gof.Op):
def
make_node
(
self
,
*
inputs
):
def
make_node
(
self
,
*
inputs
):
for
input
,
type
in
zip
(
inputs
,
self
.
input_types
):
for
input
,
type
in
zip
(
inputs
,
self
.
input_types
):
if
not
type
==
input
.
type
:
if
not
type
==
input
.
type
:
raise
TypeError
(
"Wrong type, expected
%
s but got
%
s"
%
(
type
,
input
.
type
))
raise
TypeError
(
"Wrong type, expected
%
s but got
%
s"
%
(
type
,
input
.
type
))
return
gof
.
Apply
(
self
,
return
gof
.
Apply
(
self
,
inputs
,
inputs
,
[
type
()
for
type
in
self
.
output_types
])
[
type
()
for
type
in
self
.
output_types
])
...
@@ -85,8 +90,8 @@ class OpFromGraph(gof.Op):
...
@@ -85,8 +90,8 @@ class OpFromGraph(gof.Op):
variables
=
self
.
fn
(
*
inputs
)
variables
=
self
.
fn
(
*
inputs
)
assert
len
(
variables
)
==
len
(
outputs
)
assert
len
(
variables
)
==
len
(
outputs
)
for
output
,
variable
in
zip
(
outputs
,
variables
):
for
output
,
variable
in
zip
(
outputs
,
variables
):
##TODO: when function's output-borrowing semantics are correct,
we wont need this
##TODO: when function's output-borrowing semantics are correct,
# copy anymore
#
we wont need this
copy anymore
output
[
0
]
=
variable
.
copy
()
output
[
0
]
=
variable
.
copy
()
def
grad
(
self
,
inputs
,
output_grads
):
def
grad
(
self
,
inputs
,
output_grads
):
...
@@ -94,5 +99,3 @@ class OpFromGraph(gof.Op):
...
@@ -94,5 +99,3 @@ class OpFromGraph(gof.Op):
return
[
go
(
*
(
inputs
+
output_grads
))
for
go
in
self
.
grad_ops
]
return
[
go
(
*
(
inputs
+
output_grads
))
for
go
in
self
.
grad_ops
]
else
:
else
:
raise
NotImplementedError
raise
NotImplementedError
theano/compile/tests/test_debugmode.py
浏览文件 @
f3afab87
差异被折叠。
点击展开。
theano/sandbox/cuda/tests/test_blas.py
浏览文件 @
f3afab87
差异被折叠。
点击展开。
theano/tensor/elemwise.py
浏览文件 @
f3afab87
差异被折叠。
点击展开。
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论