Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
1b1bafcb
提交
1b1bafcb
authored
4月 03, 2017
作者:
amrithasuresh
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Updated numpy as np
上级
adf96a73
隐藏空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
10 行增加
和
10 行删除
+10
-10
test_scan_utils.py
theano/scan_module/tests/test_scan_utils.py
+10
-10
没有找到文件。
theano/scan_module/tests/test_scan_utils.py
浏览文件 @
1b1bafcb
from
__future__
import
absolute_import
,
print_function
,
division
from
__future__
import
absolute_import
,
print_function
,
division
import
itertools
import
itertools
import
unittest
import
unittest
import
numpy
import
numpy
as
np
import
theano
import
theano
from
theano
import
tensor
from
theano
import
tensor
from
theano.scan_module.scan_utils
import
equal_computations
,
map_variables
from
theano.scan_module.scan_utils
import
equal_computations
,
map_variables
...
@@ -51,8 +51,8 @@ class TestMapVariables(unittest.TestCase):
...
@@ -51,8 +51,8 @@ class TestMapVariables(unittest.TestCase):
s2
,
=
map_variables
(
self
.
replacer
,
[
s
])
s2
,
=
map_variables
(
self
.
replacer
,
[
s
])
f
=
theano
.
function
([
x
,
y
,
z
],
[
s
,
s2
])
f
=
theano
.
function
([
x
,
y
,
z
],
[
s
,
s2
])
rval
=
f
(
x
=
n
umpy
.
array
([
1
,
2
,
3
],
dtype
=
numpy
.
float32
),
y
=
1
,
z
=
2
)
rval
=
f
(
x
=
n
p
.
array
([
1
,
2
,
3
],
dtype
=
np
.
float32
),
y
=
1
,
z
=
2
)
assert
n
umpy
.
array_equal
(
rval
,
[[
1
,
2
,
3
],
[
2
,
4
,
6
]])
assert
n
p
.
array_equal
(
rval
,
[[
1
,
2
,
3
],
[
2
,
4
,
6
]])
def
test_scan
(
self
):
def
test_scan
(
self
):
x
=
tensor
.
vector
(
'x'
)
x
=
tensor
.
vector
(
'x'
)
...
@@ -64,7 +64,7 @@ class TestMapVariables(unittest.TestCase):
...
@@ -64,7 +64,7 @@ class TestMapVariables(unittest.TestCase):
# should do this as well.
# should do this as well.
outer
=
tensor
.
scalar
(
"outer"
)
outer
=
tensor
.
scalar
(
"outer"
)
shared
=
theano
.
shared
(
shared
=
theano
.
shared
(
n
umpy
.
array
(
1.
,
dtype
=
theano
.
config
.
floatX
),
n
p
.
array
(
1.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"shared"
)
name
=
"shared"
)
constant
=
tensor
.
constant
(
1
,
name
=
"constant"
)
constant
=
tensor
.
constant
(
1
,
name
=
"constant"
)
...
@@ -77,7 +77,7 @@ class TestMapVariables(unittest.TestCase):
...
@@ -77,7 +77,7 @@ class TestMapVariables(unittest.TestCase):
return
r
return
r
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
outputs_info
=
[
n
umpy
.
array
(
0.
)])
outputs_info
=
[
n
p
.
array
(
0.
)])
# ensure z is owned by the outer graph so map_variables() will need to
# ensure z is owned by the outer graph so map_variables() will need to
# jump through additional hoops to placate FunctionGraph.
# jump through additional hoops to placate FunctionGraph.
t
=
z
*
s
t
=
z
*
s
...
@@ -85,8 +85,8 @@ class TestMapVariables(unittest.TestCase):
...
@@ -85,8 +85,8 @@ class TestMapVariables(unittest.TestCase):
t2
=
z
*
s2
t2
=
z
*
s2
f
=
theano
.
function
([
x
,
outer
],
[
t
,
t2
])
f
=
theano
.
function
([
x
,
outer
],
[
t
,
t2
])
rval
=
f
(
x
=
n
umpy
.
array
([
1
,
2
,
3
],
dtype
=
numpy
.
float32
),
outer
=
0.5
)
rval
=
f
(
x
=
n
p
.
array
([
1
,
2
,
3
],
dtype
=
np
.
float32
),
outer
=
0.5
)
assert
n
umpy
.
array_equal
(
rval
,
[[
1
,
3
,
6
],
[
-
1
,
-
3
,
-
6
]])
assert
n
p
.
array_equal
(
rval
,
[[
1
,
3
,
6
],
[
-
1
,
-
3
,
-
6
]])
def
test_scan_with_shared_update
(
self
):
def
test_scan_with_shared_update
(
self
):
x
=
tensor
.
vector
(
'x'
)
x
=
tensor
.
vector
(
'x'
)
...
@@ -104,7 +104,7 @@ class TestMapVariables(unittest.TestCase):
...
@@ -104,7 +104,7 @@ class TestMapVariables(unittest.TestCase):
return
r
return
r
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
outputs_info
=
[
n
umpy
.
array
(
0.
)])
outputs_info
=
[
n
p
.
array
(
0.
)])
self
.
assertRaises
(
NotImplementedError
,
self
.
assertRaises
(
NotImplementedError
,
map_variables
,
self
.
replacer
,
[
s
])
map_variables
,
self
.
replacer
,
[
s
])
...
@@ -128,7 +128,7 @@ class TestMapVariables(unittest.TestCase):
...
@@ -128,7 +128,7 @@ class TestMapVariables(unittest.TestCase):
return
r
+
counter
return
r
+
counter
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
s
,
_
=
theano
.
scan
(
step
,
sequences
=
x
,
outputs_info
=
[
n
umpy
.
array
(
0.
)])
outputs_info
=
[
n
p
.
array
(
0.
)])
self
.
assertRaises
(
NotImplementedError
,
self
.
assertRaises
(
NotImplementedError
,
map_variables
,
self
.
replacer
,
[
s
])
map_variables
,
self
.
replacer
,
[
s
])
...
@@ -137,7 +137,7 @@ class TestMapVariables(unittest.TestCase):
...
@@ -137,7 +137,7 @@ class TestMapVariables(unittest.TestCase):
# inner graph.
# inner graph.
outer
=
tensor
.
scalar
(
"outer"
)
outer
=
tensor
.
scalar
(
"outer"
)
shared
=
theano
.
shared
(
shared
=
theano
.
shared
(
n
umpy
.
array
(
1.
,
dtype
=
theano
.
config
.
floatX
),
n
p
.
array
(
1.
,
dtype
=
theano
.
config
.
floatX
),
name
=
"shared"
)
name
=
"shared"
)
constant
=
tensor
.
constant
(
1.
,
name
=
"constant"
)
constant
=
tensor
.
constant
(
1.
,
name
=
"constant"
)
z
=
outer
*
(
shared
+
constant
)
z
=
outer
*
(
shared
+
constant
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论