Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
a4a40a60
提交
a4a40a60
authored
6月 10, 2014
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1910 from nouiz/split_0idx
Allow split with 0 index
上级
f7b98a6e
ebe0a6c1
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
26 行增加
和
7 行删除
+26
-7
test_basic.py
theano/sparse/tests/test_basic.py
+1
-1
basic.py
theano/tensor/basic.py
+3
-2
test_basic.py
theano/tensor/tests/test_basic.py
+22
-4
没有找到文件。
theano/sparse/tests/test_basic.py
浏览文件 @
a4a40a60
...
...
@@ -770,7 +770,7 @@ class test_comparison(unittest.TestCase):
y
=
theano
.
tensor
.
matrix
()
m1
=
sp
.
csc_matrix
((
2
,
2
),
dtype
=
theano
.
config
.
floatX
)
m2
=
numpy
.
asarray
([[
0
,
0
],
[
0
,
0
]])
m2
=
numpy
.
asarray
([[
0
,
0
],
[
0
,
0
]]
,
dtype
=
theano
.
config
.
floatX
)
for
func
in
self
.
testsDic
:
...
...
theano/tensor/basic.py
浏览文件 @
a4a40a60
...
...
@@ -3150,8 +3150,9 @@ class Split(Op):
if
numpy
.
sum
(
splits
)
!=
len_along_axis
:
raise
ValueError
(
'The splits sum to
%
s, expected
%
s'
%
(
numpy
.
sum
(
splits
),
len_along_axis
))
if
not
python_all
(
splits
):
raise
ValueError
(
'Cannot have a split of zero.'
)
if
python_any
([
nb
<
0
for
nb
in
splits
]):
raise
ValueError
(
'Split: you try to make an ndarray with'
'negative number of elements.'
)
# Checking is done, let's roll the splitting algorithm!
# Basically we step along the given axis of x, extracting
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
a4a40a60
...
...
@@ -2343,6 +2343,7 @@ def test_batched_dot():
assert
result
.
shape
[
0
]
==
first_mat_val
.
shape
[
0
]
def
test_batched_tensordot
():
first
=
theano
.
tensor
.
tensor4
(
"first"
)
second
=
theano
.
tensor
.
tensor4
(
"second"
)
...
...
@@ -2364,10 +2365,10 @@ def test_batched_tensordot():
second_mat_val
=
numpy
.
random
.
rand
(
10
,
4
)
.
astype
(
config
.
floatX
)
result_fn
=
theano
.
function
([
first_mat
,
second_mat
],
output
)
result
=
result_fn
(
first_mat_val
,
second_mat_val
)
print
(
result
.
shape
)
assert
result
.
shape
[
0
]
==
first_mat_val
.
shape
[
0
]
assert
len
(
result
.
shape
)
==
1
def
test_tensor_values_eq_approx
():
#test, inf, -inf and nan equal themself
a
=
numpy
.
asarray
([
-
numpy
.
inf
,
-
1
,
0
,
1
,
numpy
.
inf
,
numpy
.
nan
])
...
...
@@ -3145,15 +3146,12 @@ class T_Join_and_Split(unittest.TestCase):
b_v
=
numpy
.
random
.
rand
(
4
)
f
=
theano
.
function
([
a
,
b
],
[
Ha
,
Hb
])
Ha_v
,
Hb_v
=
f
(
a_v
,
b_v
)
print
Ha_v
print
Hb_v
# The Hessian is always a matrix full of 0
assert
Ha_v
.
shape
==
(
4
,
4
)
assert
Hb_v
.
shape
==
(
4
,
4
)
assert
numpy
.
allclose
(
Ha_v
,
0.
)
assert
numpy
.
allclose
(
Hb_v
,
0.
)
def
test_join_concatenate_one_element
(
self
):
''' Fast test of concatenate as this is an alias for join.
also test that we remove the Join op if there is only 1 input'''
...
...
@@ -3547,6 +3545,26 @@ class T_Join_and_Split(unittest.TestCase):
m
=
self
.
shared
(
rng
.
rand
(
4
,
4
)
.
astype
(
self
.
floatX
))
self
.
assertRaises
(
TypeError
,
self
.
join_op
(),
0
,
v
,
m
)
def
test_split_0elem
(
self
):
rng
=
numpy
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
m
=
self
.
shared
(
rng
.
rand
(
4
,
6
)
.
astype
(
self
.
floatX
))
o
=
self
.
split_op
(
2
)(
m
,
0
,
[
4
,
0
])
f
=
function
([],
o
,
mode
=
self
.
mode
)
assert
any
([
isinstance
(
node
.
op
,
self
.
split_op
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
o1
,
o2
=
f
()
assert
numpy
.
allclose
(
o1
,
m
.
get_value
(
borrow
=
True
))
assert
numpy
.
allclose
(
o2
,
m
.
get_value
(
borrow
=
True
)[
4
:])
def
test_split_neg
(
self
):
rng
=
numpy
.
random
.
RandomState
(
seed
=
utt
.
fetch_seed
())
m
=
self
.
shared
(
rng
.
rand
(
4
,
6
)
.
astype
(
self
.
floatX
))
o
=
self
.
split_op
(
2
)(
m
,
0
,
[
5
,
-
1
])
f
=
function
([],
o
,
mode
=
self
.
mode
)
assert
any
([
isinstance
(
node
.
op
,
self
.
split_op
)
for
node
in
f
.
maker
.
fgraph
.
toposort
()])
self
.
assertRaises
(
ValueError
,
f
)
class
test_comparison
(
unittest
.
TestCase
):
"""Test <, >, <=, >=, == and !=
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论