Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
80a3a4dc
提交
80a3a4dc
authored
4月 19, 2012
作者:
Nicolas Pinto
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
MISC: pep8
上级
ceb31338
隐藏空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
70 行增加
和
55 行删除
+70
-55
__init__.py
theano/tensor/__init__.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+69
-54
没有找到文件。
theano/tensor/__init__.py
浏览文件 @
80a3a4dc
"""Define the tensor toplevel"""
"""Define the tensor toplevel"""
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
warnings
import
warnings
from
basic
import
*
from
basic
import
*
...
@@ -31,6 +30,7 @@ import sharedvar # adds shared-variable constructors
...
@@ -31,6 +30,7 @@ import sharedvar # adds shared-variable constructors
# `theano.shared` and `tensor._shared`.
# `theano.shared` and `tensor._shared`.
from
sharedvar
import
tensor_constructor
as
_shared
from
sharedvar
import
tensor_constructor
as
_shared
def
shared
(
*
args
,
**
kw
):
def
shared
(
*
args
,
**
kw
):
"""
"""
Backward-compatibility wrapper around `tensor._shared`.
Backward-compatibility wrapper around `tensor._shared`.
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
80a3a4dc
...
@@ -433,7 +433,7 @@ def makeBroadcastTester(op, expected, checks=None, name=None, **kwargs):
...
@@ -433,7 +433,7 @@ def makeBroadcastTester(op, expected, checks=None, name=None, **kwargs):
# cases we need to add it manually.
# cases we need to add it manually.
if
not
name
.
endswith
(
'Tester'
):
if
not
name
.
endswith
(
'Tester'
):
name
+=
"Tester"
name
+=
"Tester"
if
kwargs
.
has_key
(
'inplace'
)
:
if
'inplace'
in
kwargs
:
if
kwargs
[
'inplace'
]:
if
kwargs
[
'inplace'
]:
_expected
=
expected
_expected
=
expected
if
not
isinstance
(
_expected
,
dict
):
if
not
isinstance
(
_expected
,
dict
):
...
@@ -451,37 +451,42 @@ def makeBroadcastTester(op, expected, checks=None, name=None, **kwargs):
...
@@ -451,37 +451,42 @@ def makeBroadcastTester(op, expected, checks=None, name=None, **kwargs):
return
makeTester
(
name
,
op
,
expected
,
checks
,
**
kwargs
)
return
makeTester
(
name
,
op
,
expected
,
checks
,
**
kwargs
)
_good_broadcast_binary_normal
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
_good_broadcast_binary_normal
=
dict
(
not_same_dimensions
=
(
rand
(
2
,
2
),
rand
(
2
)),
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
not_same_dimensions
=
(
rand
(
2
,
2
),
rand
(
2
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
integers
=
(
randint
(
2
,
3
),
randint
(
2
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
dtype_mixup_1
=
(
rand
(
2
,
3
),
randint
(
2
,
3
)),
integers
=
(
randint
(
2
,
3
),
randint
(
2
,
3
)),
dtype_mixup_2
=
(
randint
(
2
,
3
),
rand
(
2
,
3
)),
dtype_mixup_1
=
(
rand
(
2
,
3
),
randint
(
2
,
3
)),
complex1
=
(
randcomplex
(
2
,
3
),
randcomplex
(
2
,
3
)),
dtype_mixup_2
=
(
randint
(
2
,
3
),
rand
(
2
,
3
)),
complex2
=
(
randcomplex
(
2
,
3
),
rand
(
2
,
3
)),
complex1
=
(
randcomplex
(
2
,
3
),
randcomplex
(
2
,
3
)),
# Disabled as we test the case where we reuse the same output as the first inputs.
complex2
=
(
randcomplex
(
2
,
3
),
rand
(
2
,
3
)),
# complex3=(rand(2,3),randcomplex(2,3)),
# Disabled as we test the case where we reuse the same output as the
empty
=
(
numpy
.
asarray
([]),
numpy
.
asarray
([
1
])),
# first inputs.
)
# complex3=(rand(2,3),randcomplex(2,3)),
empty
=
(
numpy
.
asarray
([]),
numpy
.
asarray
([
1
])),
_bad_build_broadcast_binary_normal
=
dict
()
# not_same_dimensions = (rand(2), rand(2, 2)))
)
_bad_runtime_broadcast_binary_normal
=
dict
(
bad_shapes
=
(
rand
(
2
,
3
),
rand
(
3
,
2
)),
_bad_build_broadcast_binary_normal
=
dict
()
bad_row
=
(
rand
(
2
,
3
),
rand
(
1
,
2
)))
_bad_runtime_broadcast_binary_normal
=
dict
(
_grad_broadcast_binary_normal
=
dict
(
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
bad_shapes
=
(
rand
(
2
,
3
),
rand
(
3
,
2
)),
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
bad_row
=
(
rand
(
2
,
3
),
rand
(
1
,
2
)))
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
_grad_broadcast_binary_normal
=
dict
(
#This don't work as verify grad don't support that
same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
)),
#empty=(numpy.asarray([]), numpy.asarray([1]))
scalar
=
(
rand
(
2
,
3
),
rand
(
1
,
1
)),
#complex1=(randcomplex(2,3),randcomplex(2,3)),
row
=
(
rand
(
2
,
3
),
rand
(
1
,
3
)),
#complex2=(randcomplex(2,3),rand(2,3)),
column
=
(
rand
(
2
,
3
),
rand
(
2
,
1
)),
# Disabled as we test the case where we reuse the same output as the first inputs.
#This don't work as verify grad don't support that
#complex3=(rand(2,3),randcomplex(2,3)),
#empty=(numpy.asarray([]), numpy.asarray([1]))
)
#complex1=(randcomplex(2,3),randcomplex(2,3)),
#complex2=(randcomplex(2,3),rand(2,3)),
# Disabled as we test the case where we reuse the same output as the
# first inputs.
#complex3=(rand(2,3),randcomplex(2,3)),
)
def
check_floatX
(
inputs
,
rval
):
def
check_floatX
(
inputs
,
rval
):
...
@@ -507,28 +512,38 @@ def check_floatX(inputs, rval):
...
@@ -507,28 +512,38 @@ def check_floatX(inputs, rval):
return
rval
return
rval
AddTester
=
makeBroadcastTester
(
op
=
add
,
AddTester
=
makeBroadcastTester
(
expected
=
lambda
*
inputs
:
check_floatX
(
inputs
,
reduce
(
lambda
x
,
y
:
x
+
y
,
inputs
)),
op
=
add
,
good
=
dict
(
three_inputs_same_shapes
=
(
rand
(
2
,
3
),
rand
(
2
,
3
),
rand
(
2
,
3
)),
expected
=
lambda
*
inputs
:
check_floatX
(
four_inputs_broadcast
=
(
rand
(
2
,
3
),
rand
(
1
,
3
),
rand
(
2
,
1
),
rand
(
1
,
1
)),
inputs
,
reduce
(
lambda
x
,
y
:
x
+
y
,
inputs
)),
**
_good_broadcast_binary_normal
),
good
=
dict
(
bad_build
=
_bad_build_broadcast_binary_normal
,
three_inputs_same_shapes
=
(
rand
(
2
,
3
),
bad_runtime
=
_bad_runtime_broadcast_binary_normal
)
rand
(
2
,
3
),
rand
(
2
,
3
)),
four_inputs_broadcast
=
(
rand
(
2
,
3
),
AddInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
add_inplace
,
rand
(
1
,
3
),
expected
=
lambda
x
,
y
:
x
+
y
,
rand
(
2
,
1
),
good
=
_good_broadcast_binary_normal
,
rand
(
1
,
1
)),
bad_build
=
_bad_build_broadcast_binary_normal
,
**
_good_broadcast_binary_normal
),
bad_runtime
=
_bad_runtime_broadcast_binary_normal
,
bad_build
=
_bad_build_broadcast_binary_normal
,
inplace
=
True
)
bad_runtime
=
_bad_runtime_broadcast_binary_normal
)
SubTester
=
makeBroadcastTester
(
op
=
sub
,
expected
=
lambda
x
,
y
:
check_floatX
((
x
,
y
),
x
-
y
),
AddInplaceTester
=
makeBroadcastTester
(
good
=
_good_broadcast_binary_normal
,
op
=
inplace
.
add_inplace
,
bad_build
=
_bad_build_broadcast_binary_normal
,
expected
=
lambda
x
,
y
:
x
+
y
,
bad_runtime
=
_bad_runtime_broadcast_binary_normal
,
good
=
_good_broadcast_binary_normal
,
grad
=
_grad_broadcast_binary_normal
)
bad_build
=
_bad_build_broadcast_binary_normal
,
bad_runtime
=
_bad_runtime_broadcast_binary_normal
,
inplace
=
True
)
SubTester
=
makeBroadcastTester
(
op
=
sub
,
expected
=
lambda
x
,
y
:
check_floatX
((
x
,
y
),
x
-
y
),
good
=
_good_broadcast_binary_normal
,
bad_build
=
_bad_build_broadcast_binary_normal
,
bad_runtime
=
_bad_runtime_broadcast_binary_normal
,
grad
=
_grad_broadcast_binary_normal
)
SubInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
sub_inplace
,
SubInplaceTester
=
makeBroadcastTester
(
op
=
inplace
.
sub_inplace
,
expected
=
lambda
x
,
y
:
x
-
y
,
expected
=
lambda
x
,
y
:
x
-
y
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论