Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5259e427
提交
5259e427
authored
1月 31, 2017
作者:
Frédéric Bastien
提交者:
GitHub
1月 31, 2017
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5456 from affanv14/indexwork
Implement indexing with empty list
上级
673a6713
7dc4b682
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
17 行增加
和
0 行删除
+17
-0
test_var.py
theano/tensor/tests/test_var.py
+13
-0
var.py
theano/tensor/var.py
+4
-0
没有找到文件。
theano/tensor/tests/test_var.py
浏览文件 @
5259e427
...
@@ -26,6 +26,19 @@ def test_numpy_method():
...
@@ -26,6 +26,19 @@ def test_numpy_method():
np
.
nan_to_num
(
fct
(
data
)))
np
.
nan_to_num
(
fct
(
data
)))
def
test_empty_list_indexing
():
ynp
=
np
.
zeros
((
2
,
2
))[:,
[]]
znp
=
np
.
zeros
((
2
,
2
))[:,
()]
data
=
[[
0
,
0
],
[
0
,
0
]]
x
=
tt
.
dmatrix
(
'x'
)
y
=
x
[:,
[]]
z
=
x
[:,
()]
fy
=
theano
.
function
([
x
],
y
)
fz
=
theano
.
function
([
x
],
z
)
assert_equal
(
fy
(
data
)
.
shape
,
ynp
.
shape
)
assert_equal
(
fz
(
data
)
.
shape
,
znp
.
shape
)
def
test_copy
():
def
test_copy
():
x
=
tt
.
dmatrix
(
'x'
)
x
=
tt
.
dmatrix
(
'x'
)
data
=
np
.
random
.
rand
(
5
,
5
)
data
=
np
.
random
.
rand
(
5
,
5
)
...
...
theano/tensor/var.py
浏览文件 @
5259e427
...
@@ -501,6 +501,10 @@ class _tensor_py_operators(object):
...
@@ -501,6 +501,10 @@ class _tensor_py_operators(object):
args
[
ellipsis_at
:
ellipsis_at
+
1
]
=
(
args
[
ellipsis_at
:
ellipsis_at
+
1
]
=
(
[
slice
(
None
)]
*
(
self
.
ndim
-
(
len
(
args
)
-
1
-
new_axes
)))
[
slice
(
None
)]
*
(
self
.
ndim
-
(
len
(
args
)
-
1
-
new_axes
)))
# Force input to be int64 datatype if input is an empty list or tuple
# Else leave it as is if it is a real number
args
=
tuple
([
numpy
.
array
(
inp
,
dtype
=
numpy
.
int64
)
if
(
inp
==
[]
or
inp
==
())
else
inp
for
inp
in
args
])
# Convert python literals to theano constants
# Convert python literals to theano constants
args
=
theano
.
tensor
.
subtensor
.
make_constant
(
args
)
args
=
theano
.
tensor
.
subtensor
.
make_constant
(
args
)
# Determine if advanced indexing is needed or not
# Determine if advanced indexing is needed or not
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论