Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
eb1d2f9f
提交
eb1d2f9f
authored
5月 20, 2014
作者:
Hengjean
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Added constant input support for GetItem
上级
6b60c53a
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
39 行增加
和
5 行删除
+39
-5
basic.py
theano/typed_list/basic.py
+7
-1
test_basic.py
theano/typed_list/tests/test_basic.py
+32
-4
没有找到文件。
theano/typed_list/basic.py
浏览文件 @
eb1d2f9f
...
@@ -39,7 +39,13 @@ class GetItem(Op):
...
@@ -39,7 +39,13 @@ class GetItem(Op):
def
make_node
(
self
,
x
,
index
):
def
make_node
(
self
,
x
,
index
):
assert
isinstance
(
x
.
type
,
TypedListType
)
assert
isinstance
(
x
.
type
,
TypedListType
)
assert
isinstance
(
index
,
Variable
)
if
not
isinstance
(
index
,
Variable
):
if
isinstance
(
index
,
slice
):
index
=
Constant
(
SliceType
(),
index
)
return
Apply
(
self
,
[
x
,
index
],
[
x
.
type
()])
else
:
index
=
T
.
constant
(
index
,
ndim
=
0
)
return
Apply
(
self
,
[
x
,
index
],
[
x
.
ttype
()])
if
isinstance
(
index
.
type
,
SliceType
):
if
isinstance
(
index
.
type
,
SliceType
):
return
Apply
(
self
,
[
x
,
index
],
[
x
.
type
()])
return
Apply
(
self
,
[
x
,
index
],
[
x
.
type
()])
elif
isinstance
(
index
,
T
.
TensorVariable
)
and
index
.
ndim
==
0
:
elif
isinstance
(
index
,
T
.
TensorVariable
)
and
index
.
ndim
==
0
:
...
...
theano/typed_list/tests/test_basic.py
浏览文件 @
eb1d2f9f
...
@@ -70,6 +70,13 @@ class test_get_item(unittest.TestCase):
...
@@ -70,6 +70,13 @@ class test_get_item(unittest.TestCase):
self
.
assertTrue
(
numpy
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
0
)),
x
))
self
.
assertTrue
(
numpy
.
array_equal
(
f
([
x
],
numpy
.
asarray
(
0
)),
x
))
z
=
mySymbolicMatricesList
[
0
:
1
:
1
]
f
=
theano
.
function
([
mySymbolicMatricesList
],
z
)
self
.
assertTrue
(
numpy
.
array_equal
(
f
([
x
]),
[
x
]))
def
test_wrong_input
(
self
):
def
test_wrong_input
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))()
theano
.
config
.
floatX
,
(
False
,
False
)))()
...
@@ -78,17 +85,38 @@ class test_get_item(unittest.TestCase):
...
@@ -78,17 +85,38 @@ class test_get_item(unittest.TestCase):
self
.
assertRaises
(
TypeError
,
GetItem
(),
mySymbolicMatricesList
,
self
.
assertRaises
(
TypeError
,
GetItem
(),
mySymbolicMatricesList
,
mySymbolicMatrix
)
mySymbolicMatrix
)
def
test_constant_input
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))()
z
=
GetItem
()(
mySymbolicMatricesList
,
0
)
f
=
theano
.
function
([
mySymbolicMatricesList
],
z
)
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
self
.
assertTrue
(
numpy
.
array_equal
(
f
([
x
]),
x
))
z
=
GetItem
()(
mySymbolicMatricesList
,
slice
(
0
,
1
,
1
))
f
=
theano
.
function
([
mySymbolicMatricesList
],
z
)
self
.
assertTrue
(
numpy
.
array_equal
(
f
([
x
]),
[
x
]))
class
test_append
(
unittest
.
TestCase
):
class
test_append
(
unittest
.
TestCase
):
def
test_
sanity_check
(
self
):
def
test_
inplace
(
self
):
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))()
theano
.
config
.
floatX
,
(
False
,
False
)))()
myMatrix
=
T
.
matrix
()
myMatrix
=
T
.
matrix
()
z
=
Append
()(
mySymbolicMatricesList
,
myMatrix
)
z
=
Append
()(
mySymbolicMatricesList
,
myMatrix
)
f
=
theano
.
function
([
mySymbolicMatricesList
,
myMatrix
],
z
)
f
=
theano
.
function
([
mySymbolicMatricesList
,
myMatrix
],
z
,
accept_inplace
=
True
)
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
...
@@ -99,7 +127,7 @@ class test_append(unittest.TestCase):
...
@@ -99,7 +127,7 @@ class test_append(unittest.TestCase):
class
test_extend
(
unittest
.
TestCase
):
class
test_extend
(
unittest
.
TestCase
):
def
test_
sanity_check
(
self
):
def
test_
inplace
(
self
):
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList1
=
TypedListType
(
T
.
TensorType
(
theano
.
config
.
floatX
,
(
False
,
False
)))()
theano
.
config
.
floatX
,
(
False
,
False
)))()
mySymbolicMatricesList2
=
TypedListType
(
T
.
TensorType
(
mySymbolicMatricesList2
=
TypedListType
(
T
.
TensorType
(
...
@@ -108,7 +136,7 @@ class test_extend(unittest.TestCase):
...
@@ -108,7 +136,7 @@ class test_extend(unittest.TestCase):
z
=
Extend
()(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
z
=
Extend
()(
mySymbolicMatricesList1
,
mySymbolicMatricesList2
)
f
=
theano
.
function
([
mySymbolicMatricesList1
,
mySymbolicMatricesList2
],
f
=
theano
.
function
([
mySymbolicMatricesList1
,
mySymbolicMatricesList2
],
z
)
z
,
accept_inplace
=
True
)
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
x
=
rand_ranged_matrix
(
-
1000
,
1000
,
[
100
,
101
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论