Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
49e25b0f
提交
49e25b0f
authored
12月 20, 2013
作者:
Frederic
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Raise error if the user try to use shared variable.
上级
2d4eca23
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
22 行增加
和
1 行删除
+22
-1
builders.py
theano/compile/builders.py
+4
-0
test_builders.py
theano/compile/tests/test_builders.py
+18
-1
没有找到文件。
theano/compile/builders.py
浏览文件 @
49e25b0f
...
@@ -47,6 +47,10 @@ class OpFromGraph(gof.Op):
...
@@ -47,6 +47,10 @@ class OpFromGraph(gof.Op):
if
'updates'
in
kwargs
:
if
'updates'
in
kwargs
:
raise
TypeError
(
'updates are not allowed in kwargs'
)
raise
TypeError
(
'updates are not allowed in kwargs'
)
shared_inputs
=
[
var
for
var
in
gof
.
graph
.
inputs
(
outputs
)
if
isinstance
(
var
,
SharedVariable
)]
if
shared_inputs
:
raise
NotImplementedError
(
"OpFromGraph do not support SharedVariable in the inner graph"
)
# TODO: the graph may have implicit inputs like
# TODO: the graph may have implicit inputs like
# SharedVariable instances.
# SharedVariable instances.
# what impact to they have on the validity of this Op?
# what impact to they have on the validity of this Op?
...
...
theano/compile/tests/test_builders.py
浏览文件 @
49e25b0f
import
numpy
import
numpy
import
unittest
import
unittest
from
theano
import
config
from
theano
import
config
,
shared
from
theano.compile
import
function
from
theano.compile
import
function
...
@@ -56,6 +56,23 @@ class T_OpFromGraph(unittest.TestCase):
...
@@ -56,6 +56,23 @@ class T_OpFromGraph(unittest.TestCase):
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
assert
numpy
.
all
(
11.0
==
fn
(
xv
,
yv
,
zv
))
assert
numpy
.
all
(
11.0
==
fn
(
xv
,
yv
,
zv
))
def
test_shared
(
self
):
x
,
y
,
z
=
T
.
matrices
(
'xyz'
)
s
=
shared
(
numpy
.
random
.
rand
(
2
,
2
)
.
astype
(
config
.
floatX
))
e
=
x
+
y
*
z
+
s
self
.
assertRaises
(
NotImplementedError
,
OpFromGraph
,
[
x
,
y
,
z
],
[
e
],
mode
=
'FAST_RUN'
)
return
op
=
OpFromGraph
([
x
,
y
,
z
],
[
e
],
mode
=
'FAST_RUN'
)
f
=
op
(
x
,
y
,
z
)
-
op
(
y
,
z
,
x
)
# (1+3*5=array of 16) - (3+1*5=array of 8)
fn
=
function
([
x
,
y
,
z
],
f
)
xv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
yv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
3
zv
=
numpy
.
ones
((
2
,
2
),
dtype
=
config
.
floatX
)
*
5
#print function, function.__module__
#print fn.maker.fgraph.toposort()
assert
numpy
.
allclose
(
8.0
,
fn
(
xv
,
yv
,
zv
))
assert
numpy
.
allclose
(
8.0
,
fn
(
xv
,
yv
,
zv
))
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
unittest
.
main
()
unittest
.
main
()
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论