Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
b9f3daec
提交
b9f3daec
authored
3月 23, 2011
作者:
Frederic Bastien
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
moved 2 functions around.
上级
a7453163
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
35 行增加
和
33 行删除
+35
-33
python25.py
theano/gof/python25.py
+24
-0
test_basic.py
theano/tensor/tests/test_basic.py
+11
-33
没有找到文件。
theano/gof/python25.py
浏览文件 @
b9f3daec
...
@@ -69,3 +69,27 @@ else:
...
@@ -69,3 +69,27 @@ else:
partial
=
functools
.
partial
partial
=
functools
.
partial
defaultdict
=
collections
.
defaultdict
defaultdict
=
collections
.
defaultdict
__all__
=
[
'all'
,
'any'
]
__all__
=
[
'all'
,
'any'
]
if
sys
.
version_info
[:
2
]
<
(
2
,
6
):
# Borrowed from Python docs
def
combinations
(
iterable
,
r
):
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
pool
=
tuple
(
iterable
)
n
=
len
(
pool
)
if
r
>
n
:
return
indices
=
range
(
r
)
yield
tuple
(
pool
[
i
]
for
i
in
indices
)
while
True
:
for
i
in
reversed
(
range
(
r
)):
if
indices
[
i
]
!=
i
+
n
-
r
:
break
else
:
return
indices
[
i
]
+=
1
for
j
in
range
(
i
+
1
,
r
):
indices
[
j
]
=
indices
[
j
-
1
]
+
1
yield
tuple
(
pool
[
i
]
for
i
in
indices
)
else
:
from
itertools
import
combinations
theano/tensor/tests/test_basic.py
浏览文件 @
b9f3daec
...
@@ -15,7 +15,7 @@ from theano.tensor import inplace
...
@@ -15,7 +15,7 @@ from theano.tensor import inplace
from
copy
import
copy
from
copy
import
copy
from
theano
import
compile
,
config
from
theano
import
compile
,
config
from
theano
import
gof
from
theano
import
gof
from
theano.gof.python25
import
any
,
all
from
theano.gof.python25
import
any
,
all
,
combinations
from
theano.compile.mode
import
get_default_mode
from
theano.compile.mode
import
get_default_mode
from
theano
import
function
from
theano
import
function
...
@@ -218,6 +218,16 @@ def randint_ranged(min, max, shape):
...
@@ -218,6 +218,16 @@ def randint_ranged(min, max, shape):
def
randc128_ranged
(
min
,
max
,
shape
):
def
randc128_ranged
(
min
,
max
,
shape
):
return
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
)
*
(
max
-
min
)
+
min
,
dtype
=
'complex128'
)
return
numpy
.
asarray
(
numpy
.
random
.
rand
(
*
shape
)
*
(
max
-
min
)
+
min
,
dtype
=
'complex128'
)
def
rand_of_dtype
(
shape
,
dtype
):
if
'int'
in
dtype
:
return
randint
(
*
shape
)
.
astype
(
dtype
)
elif
'float'
in
dtype
:
return
rand
(
*
shape
)
.
astype
(
dtype
)
elif
'complex'
in
dtype
:
return
randcomplex
(
*
shape
)
.
astype
(
dtype
)
else
:
raise
TypeError
()
def
makeBroadcastTester
(
op
,
expected
,
checks
=
{},
**
kwargs
):
def
makeBroadcastTester
(
op
,
expected
,
checks
=
{},
**
kwargs
):
name
=
str
(
op
)
+
"Tester"
name
=
str
(
op
)
+
"Tester"
if
kwargs
.
has_key
(
'inplace'
):
if
kwargs
.
has_key
(
'inplace'
):
...
@@ -792,43 +802,11 @@ DotTester = makeTester(name = 'DotTester',
...
@@ -792,43 +802,11 @@ DotTester = makeTester(name = 'DotTester',
def
_numpy_second
(
x
,
y
):
def
_numpy_second
(
x
,
y
):
return
numpy
.
broadcast_arrays
(
x
,
y
)[
1
]
return
numpy
.
broadcast_arrays
(
x
,
y
)[
1
]
def
combinations
(
iterable
,
r
):
# Borrowed from Python docs - can be removed when we drop
# support for 2.4/2.5
# combinations('ABCD', 2) --> AB AC AD BC BD CD
# combinations(range(4), 3) --> 012 013 023 123
pool
=
tuple
(
iterable
)
n
=
len
(
pool
)
if
r
>
n
:
return
indices
=
range
(
r
)
yield
tuple
(
pool
[
i
]
for
i
in
indices
)
while
True
:
for
i
in
reversed
(
range
(
r
)):
if
indices
[
i
]
!=
i
+
n
-
r
:
break
else
:
return
indices
[
i
]
+=
1
for
j
in
range
(
i
+
1
,
r
):
indices
[
j
]
=
indices
[
j
-
1
]
+
1
yield
tuple
(
pool
[
i
]
for
i
in
indices
)
ALL_DTYPES
=
(
'int8'
,
'int16'
,
'int32'
,
'int64'
,
ALL_DTYPES
=
(
'int8'
,
'int16'
,
'int32'
,
'int64'
,
'float32'
,
'float64'
,
'complex64'
,
'complex128'
)
'float32'
,
'float64'
,
'complex64'
,
'complex128'
)
REAL_DTYPES
=
ALL_DTYPES
[:
-
2
]
REAL_DTYPES
=
ALL_DTYPES
[:
-
2
]
COMPLEX_DTYPES
=
ALL_DTYPES
[
-
2
:]
COMPLEX_DTYPES
=
ALL_DTYPES
[
-
2
:]
def
rand_of_dtype
(
shape
,
dtype
):
if
'int'
in
dtype
:
return
randint
(
*
shape
)
.
astype
(
dtype
)
elif
'float'
in
dtype
:
return
rand
(
*
shape
)
.
astype
(
dtype
)
elif
'complex'
in
dtype
:
return
randcomplex
(
*
shape
)
.
astype
(
dtype
)
else
:
raise
TypeError
()
def
multi_dtype_checks
(
shape1
,
shape2
,
dtypes
=
ALL_DTYPES
,
nameprefix
=
''
):
def
multi_dtype_checks
(
shape1
,
shape2
,
dtypes
=
ALL_DTYPES
,
nameprefix
=
''
):
for
dtype1
,
dtype2
in
combinations
(
dtypes
,
2
):
for
dtype1
,
dtype2
in
combinations
(
dtypes
,
2
):
name1
=
'
%
s_
%
s_
%
s'
%
(
nameprefix
,
dtype1
,
dtype2
)
name1
=
'
%
s_
%
s_
%
s'
%
(
nameprefix
,
dtype1
,
dtype2
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论