Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
d7e5e496
提交
d7e5e496
authored
8月 16, 2016
作者:
Frédéric Bastien
提交者:
GitHub
8月 16, 2016
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4861 from gvtulder/f-tensor5
Add tensor5, dtensor5 etc.
上级
c5d3942b
af08db3b
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
128 行增加
和
91 行删除
+128
-91
generate_dtype_tensor_table.py
doc/generate_dtype_tensor_table.py
+5
-4
basic.txt
doc/library/tensor/basic.txt
+76
-64
adding.txt
doc/tutorial/adding.txt
+7
-7
test_dnn.py
theano/gpuarray/tests/test_dnn.py
+3
-4
test_dnn.py
theano/sandbox/cuda/tests/test_dnn.py
+9
-12
basic.py
theano/tensor/basic.py
+28
-0
没有找到文件。
doc/generate_dtype_tensor_table.py
浏览文件 @
d7e5e496
...
@@ -17,17 +17,18 @@ shapes = [
...
@@ -17,17 +17,18 @@ shapes = [
(
'col'
,
(
False
,
True
)),
(
'col'
,
(
False
,
True
)),
(
'matrix'
,
(
False
,
False
)),
(
'matrix'
,
(
False
,
False
)),
(
'tensor3'
,
(
False
,
False
,
False
)),
(
'tensor3'
,
(
False
,
False
,
False
)),
(
'tensor4'
,
(
False
,
False
,
False
,
False
)),]
(
'tensor4'
,
(
False
,
False
,
False
,
False
)),
(
'tensor5'
,
(
False
,
False
,
False
,
False
,
False
)),]
hdr
=
'============ =========== ==== ===========
================================='
hdr
=
'============ =========== ==== ===========
= ==
================================='
print
(
hdr
)
print
(
hdr
)
print
(
'Constructor dtype ndim shape broadcastable'
)
print
(
'Constructor dtype ndim shape
broadcastable'
)
print
(
hdr
)
print
(
hdr
)
for
letter
in
letters
:
for
letter
in
letters
:
for
shape
in
shapes
:
for
shape
in
shapes
:
suff
=
',)'
if
len
(
shape
[
1
])
==
1
else
')'
suff
=
',)'
if
len
(
shape
[
1
])
==
1
else
')'
s
=
'('
+
','
.
join
(
'1'
if
b
else
'?'
for
b
in
shape
[
1
])
+
suff
s
=
'('
+
','
.
join
(
'1'
if
b
else
'?'
for
b
in
shape
[
1
])
+
suff
print
(
'
%
s
%-10
s
%-10
s
%-4
s
%-1
0
s
%-20
s'
%
(
print
(
'
%
s
%-10
s
%-10
s
%-4
s
%-1
1
s
%-20
s'
%
(
letter
[
0
],
shape
[
0
],
letter
[
1
],
len
(
shape
[
1
]),
s
,
shape
[
1
]
letter
[
0
],
shape
[
0
],
letter
[
1
],
len
(
shape
[
1
]),
s
,
shape
[
1
]
))
))
print
(
hdr
)
print
(
hdr
)
doc/library/tensor/basic.txt
浏览文件 @
d7e5e496
...
@@ -85,6 +85,10 @@ floating-point precision.
...
@@ -85,6 +85,10 @@ floating-point precision.
Return a Variable for a 4-dimensional ndarray
Return a Variable for a 4-dimensional ndarray
.. function:: tensor5(name=None, dtype=config.floatX)
Return a Variable for a 5-dimensional ndarray
.. #COMMENT
.. #COMMENT
Each of the types described above can be constructed by two methods:
Each of the types described above can be constructed by two methods:
a singular version (e.g., :ref:`dmatrix <libdoc_tensor_creation>`)
a singular version (e.g., :ref:`dmatrix <libdoc_tensor_creation>`)
...
@@ -112,66 +116,74 @@ They are all callable, and accept an optional ``name`` argument. So for example
...
@@ -112,66 +116,74 @@ They are all callable, and accept an optional ``name`` argument. So for example
table generated by
table generated by
$ python Theano/doc/generate_dtype_tensor_table.py
$ python Theano/doc/generate_dtype_tensor_table.py
============ =========== ==== =========== =================================
============ =========== ==== ============ ===================================
Constructor dtype ndim shape broadcastable
Constructor dtype ndim shape broadcastable
============ =========== ==== =========== =================================
============ =========== ==== ============ ===================================
bscalar int8 0 () ()
bscalar int8 0 () ()
bvector int8 1 (?,) (False,)
bvector int8 1 (?,) (False,)
brow int8 2 (1,?) (True, False)
brow int8 2 (1,?) (True, False)
bcol int8 2 (?,1) (False, True)
bcol int8 2 (?,1) (False, True)
bmatrix int8 2 (?,?) (False, False)
bmatrix int8 2 (?,?) (False, False)
btensor3 int8 3 (?,?,?) (False, False, False)
btensor3 int8 3 (?,?,?) (False, False, False)
btensor4 int8 4 (?,?,?,?) (False, False, False, False)
btensor4 int8 4 (?,?,?,?) (False, False, False, False)
wscalar int16 0 () ()
btensor5 int8 5 (?,?,?,?,?) (False, False, False, False, False)
wvector int16 1 (?,) (False,)
wscalar int16 0 () ()
wrow int16 2 (1,?) (True, False)
wvector int16 1 (?,) (False,)
wcol int16 2 (?,1) (False, True)
wrow int16 2 (1,?) (True, False)
wmatrix int16 2 (?,?) (False, False)
wcol int16 2 (?,1) (False, True)
wtensor3 int16 3 (?,?,?) (False, False, False)
wmatrix int16 2 (?,?) (False, False)
wtensor4 int16 4 (?,?,?,?) (False, False, False, False)
wtensor3 int16 3 (?,?,?) (False, False, False)
iscalar int32 0 () ()
wtensor4 int16 4 (?,?,?,?) (False, False, False, False)
ivector int32 1 (?,) (False,)
wtensor5 int16 5 (?,?,?,?,?) (False, False, False, False, False)
irow int32 2 (1,?) (True, False)
iscalar int32 0 () ()
icol int32 2 (?,1) (False, True)
ivector int32 1 (?,) (False,)
imatrix int32 2 (?,?) (False, False)
irow int32 2 (1,?) (True, False)
itensor3 int32 3 (?,?,?) (False, False, False)
icol int32 2 (?,1) (False, True)
itensor4 int32 4 (?,?,?,?) (False, False, False, False)
imatrix int32 2 (?,?) (False, False)
lscalar int64 0 () ()
itensor3 int32 3 (?,?,?) (False, False, False)
lvector int64 1 (?,) (False,)
itensor4 int32 4 (?,?,?,?) (False, False, False, False)
lrow int64 2 (1,?) (True, False)
itensor5 int32 5 (?,?,?,?,?) (False, False, False, False, False)
lcol int64 2 (?,1) (False, True)
lscalar int64 0 () ()
lmatrix int64 2 (?,?) (False, False)
lvector int64 1 (?,) (False,)
ltensor3 int64 3 (?,?,?) (False, False, False)
lrow int64 2 (1,?) (True, False)
ltensor4 int64 4 (?,?,?,?) (False, False, False, False)
lcol int64 2 (?,1) (False, True)
dscalar float64 0 () ()
lmatrix int64 2 (?,?) (False, False)
dvector float64 1 (?,) (False,)
ltensor3 int64 3 (?,?,?) (False, False, False)
drow float64 2 (1,?) (True, False)
ltensor4 int64 4 (?,?,?,?) (False, False, False, False)
dcol float64 2 (?,1) (False, True)
ltensor5 int64 5 (?,?,?,?,?) (False, False, False, False, False)
dmatrix float64 2 (?,?) (False, False)
dscalar float64 0 () ()
dtensor3 float64 3 (?,?,?) (False, False, False)
dvector float64 1 (?,) (False,)
dtensor4 float64 4 (?,?,?,?) (False, False, False, False)
drow float64 2 (1,?) (True, False)
fscalar float32 0 () ()
dcol float64 2 (?,1) (False, True)
fvector float32 1 (?,) (False,)
dmatrix float64 2 (?,?) (False, False)
frow float32 2 (1,?) (True, False)
dtensor3 float64 3 (?,?,?) (False, False, False)
fcol float32 2 (?,1) (False, True)
dtensor4 float64 4 (?,?,?,?) (False, False, False, False)
fmatrix float32 2 (?,?) (False, False)
dtensor5 float64 5 (?,?,?,?,?) (False, False, False, False, False)
ftensor3 float32 3 (?,?,?) (False, False, False)
fscalar float32 0 () ()
ftensor4 float32 4 (?,?,?,?) (False, False, False, False)
fvector float32 1 (?,) (False,)
cscalar complex64 0 () ()
frow float32 2 (1,?) (True, False)
cvector complex64 1 (?,) (False,)
fcol float32 2 (?,1) (False, True)
crow complex64 2 (1,?) (True, False)
fmatrix float32 2 (?,?) (False, False)
ccol complex64 2 (?,1) (False, True)
ftensor3 float32 3 (?,?,?) (False, False, False)
cmatrix complex64 2 (?,?) (False, False)
ftensor4 float32 4 (?,?,?,?) (False, False, False, False)
ctensor3 complex64 3 (?,?,?) (False, False, False)
ftensor5 float32 5 (?,?,?,?,?) (False, False, False, False, False)
ctensor4 complex64 4 (?,?,?,?) (False, False, False, False)
cscalar complex64 0 () ()
zscalar complex128 0 () ()
cvector complex64 1 (?,) (False,)
zvector complex128 1 (?,) (False,)
crow complex64 2 (1,?) (True, False)
zrow complex128 2 (1,?) (True, False)
ccol complex64 2 (?,1) (False, True)
zcol complex128 2 (?,1) (False, True)
cmatrix complex64 2 (?,?) (False, False)
zmatrix complex128 2 (?,?) (False, False)
ctensor3 complex64 3 (?,?,?) (False, False, False)
ztensor3 complex128 3 (?,?,?) (False, False, False)
ctensor4 complex64 4 (?,?,?,?) (False, False, False, False)
ztensor4 complex128 4 (?,?,?,?) (False, False, False, False)
ctensor5 complex64 5 (?,?,?,?,?) (False, False, False, False, False)
============ =========== ==== =========== =================================
zscalar complex128 0 () ()
zvector complex128 1 (?,) (False,)
zrow complex128 2 (1,?) (True, False)
zcol complex128 2 (?,1) (False, True)
zmatrix complex128 2 (?,?) (False, False)
ztensor3 complex128 3 (?,?,?) (False, False, False)
ztensor4 complex128 4 (?,?,?,?) (False, False, False, False)
ztensor5 complex128 5 (?,?,?,?,?) (False, False, False, False, False)
============ =========== ==== ============ ===================================
Plural Constructors
Plural Constructors
--------------------------
--------------------------
...
@@ -220,11 +232,11 @@ If you would like to construct a tensor variable with a non-standard
...
@@ -220,11 +232,11 @@ If you would like to construct a tensor variable with a non-standard
broadcasting pattern, or a larger number of dimensions you'll need to create
broadcasting pattern, or a larger number of dimensions you'll need to create
your own :class:`TensorType` instance. You create such an instance by passing
your own :class:`TensorType` instance. You create such an instance by passing
the dtype and broadcasting pattern to the constructor. For example, you
the dtype and broadcasting pattern to the constructor. For example, you
can create your own
5
-dimensional tensor type
can create your own
6
-dimensional tensor type
>>> dtensor
5 = TensorType('float64', (False,)*5
)
>>> dtensor
6 = TensorType('float64', (False,)*6
)
>>> x = dtensor
5
()
>>> x = dtensor
6
()
>>> z = dtensor
5
('z')
>>> z = dtensor
6
('z')
You can also redefine some of the provided types and they will interact
You can also redefine some of the provided types and they will interact
correctly:
correctly:
...
...
doc/tutorial/adding.txt
浏览文件 @
d7e5e496
...
@@ -175,13 +175,13 @@ by :ref:`broadcasting <libdoc_tensor_broadcastable>`.
...
@@ -175,13 +175,13 @@ by :ref:`broadcasting <libdoc_tensor_broadcastable>`.
The following types are available:
The following types are available:
* **byte**: ``bscalar, bvector, bmatrix, brow, bcol, btensor3, btensor4``
* **byte**: ``bscalar, bvector, bmatrix, brow, bcol, btensor3, btensor4
, btensor5
``
* **16-bit integers**: ``wscalar, wvector, wmatrix, wrow, wcol, wtensor3, wtensor4``
* **16-bit integers**: ``wscalar, wvector, wmatrix, wrow, wcol, wtensor3, wtensor4
, wtensor5
``
* **32-bit integers**: ``iscalar, ivector, imatrix, irow, icol, itensor3, itensor4``
* **32-bit integers**: ``iscalar, ivector, imatrix, irow, icol, itensor3, itensor4
, itensor5
``
* **64-bit integers**: ``lscalar, lvector, lmatrix, lrow, lcol, ltensor3, ltensor4``
* **64-bit integers**: ``lscalar, lvector, lmatrix, lrow, lcol, ltensor3, ltensor4
, ltensor5
``
* **float**: ``fscalar, fvector, fmatrix, frow, fcol, ftensor3, ftensor4``
* **float**: ``fscalar, fvector, fmatrix, frow, fcol, ftensor3, ftensor4
, ftensor5
``
* **double**: ``dscalar, dvector, dmatrix, drow, dcol, dtensor3, dtensor4``
* **double**: ``dscalar, dvector, dmatrix, drow, dcol, dtensor3, dtensor4
, dtensor5
``
* **complex**: ``cscalar, cvector, cmatrix, crow, ccol, ctensor3, ctensor4``
* **complex**: ``cscalar, cvector, cmatrix, crow, ccol, ctensor3, ctensor4
, ctensor5
``
The previous list is not exhaustive and a guide to all types compatible
The previous list is not exhaustive and a guide to all types compatible
with NumPy arrays may be found here: :ref:`tensor creation<libdoc_tensor_creation>`.
with NumPy arrays may be found here: :ref:`tensor creation<libdoc_tensor_creation>`.
...
...
theano/gpuarray/tests/test_dnn.py
浏览文件 @
d7e5e496
...
@@ -479,10 +479,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
...
@@ -479,10 +479,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
@parameterized.expand
(
product
(
border_modes
,
conv_modes
),
utt
.
custom_name_func
)
@parameterized.expand
(
product
(
border_modes
,
conv_modes
),
utt
.
custom_name_func
)
def
test_conv3d_none
(
self
,
border_mode
,
conv_mode
):
def
test_conv3d_none
(
self
,
border_mode
,
conv_mode
):
ftensor5
=
T
.
TensorType
(
dtype
=
"float32"
,
broadcastable
=
(
False
,)
*
5
)
self
.
_test_conv
(
T
.
ftensor5
(
'img'
),
self
.
_test_conv
(
ftensor5
(
'img'
),
T
.
ftensor5
(
'kerns'
),
ftensor5
(
'kerns'
),
T
.
ftensor5
(
'out'
),
ftensor5
(
'out'
),
numpy
.
random
.
rand
(
10
,
2
,
6
,
4
,
11
),
numpy
.
random
.
rand
(
10
,
2
,
6
,
4
,
11
),
numpy
.
random
.
rand
(
8
,
2
,
4
,
3
,
1
),
numpy
.
random
.
rand
(
8
,
2
,
4
,
3
,
1
),
border_mode
,
border_mode
,
...
...
theano/sandbox/cuda/tests/test_dnn.py
浏览文件 @
d7e5e496
...
@@ -938,10 +938,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
...
@@ -938,10 +938,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
def
test_conv3d
(
self
):
def
test_conv3d
(
self
):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
ftensor5
=
T
.
TensorType
(
dtype
=
"float32"
,
broadcastable
=
(
False
,)
*
5
)
img
=
T
.
ftensor5
(
'img'
)
img
=
ftensor5
(
'img'
)
kerns
=
T
.
ftensor5
(
'kerns'
)
kerns
=
ftensor5
(
'kerns'
)
out
=
T
.
ftensor5
(
'out'
)
out
=
ftensor5
(
'out'
)
img_val
=
numpy
.
asarray
(
img_val
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
10
,
2
,
6
,
4
,
11
),
numpy
.
random
.
rand
(
10
,
2
,
6
,
4
,
11
),
dtype
=
'float32'
dtype
=
'float32'
...
@@ -1026,10 +1025,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
...
@@ -1026,10 +1025,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
def
test_conv3d_gradw
(
self
):
def
test_conv3d_gradw
(
self
):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
ftensor5
=
T
.
TensorType
(
dtype
=
"float32"
,
broadcastable
=
(
False
,)
*
5
)
img
=
T
.
ftensor5
(
'img'
)
img
=
ftensor5
(
'img'
)
kerns
=
T
.
ftensor5
(
'kerns'
)
kerns
=
ftensor5
(
'kerns'
)
out
=
T
.
ftensor5
(
'out'
)
out
=
ftensor5
(
'out'
)
img_val
=
numpy
.
asarray
(
img_val
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
9
,
2
,
4
,
8
,
13
),
numpy
.
random
.
rand
(
9
,
2
,
4
,
8
,
13
),
dtype
=
'float32'
dtype
=
'float32'
...
@@ -1116,10 +1114,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
...
@@ -1116,10 +1114,9 @@ class TestDnnInferShapes(utt.InferShapeTester):
def
test_conv3d_gradi
(
self
):
def
test_conv3d_gradi
(
self
):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
if
not
(
cuda
.
dnn
.
dnn_available
()
and
dnn
.
version
()
>=
(
2000
,
2000
)):
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
raise
SkipTest
(
'"cuDNN 3D convolution requires cuDNN v2'
)
ftensor5
=
T
.
TensorType
(
dtype
=
"float32"
,
broadcastable
=
(
False
,)
*
5
)
img
=
T
.
ftensor5
(
'img'
)
img
=
ftensor5
(
'img'
)
kerns
=
T
.
ftensor5
(
'kerns'
)
kerns
=
ftensor5
(
'kerns'
)
out
=
T
.
ftensor5
(
'out'
)
out
=
ftensor5
(
'out'
)
img_val
=
numpy
.
asarray
(
img_val
=
numpy
.
asarray
(
numpy
.
random
.
rand
(
8
,
4
,
6
,
7
,
11
),
numpy
.
random
.
rand
(
8
,
4
,
6
,
7
,
11
),
dtype
=
'float32'
dtype
=
'float32'
...
...
theano/tensor/basic.py
浏览文件 @
d7e5e496
...
@@ -1030,6 +1030,34 @@ def tensor4(name=None, dtype=None):
...
@@ -1030,6 +1030,34 @@ def tensor4(name=None, dtype=None):
tensor4s
,
ftensor4s
,
dtensor4s
,
itensor4s
,
ltensor4s
=
_multi
(
tensor4s
,
ftensor4s
,
dtensor4s
,
itensor4s
,
ltensor4s
=
_multi
(
tensor4
,
ftensor4
,
dtensor4
,
itensor4
,
ltensor4
)
tensor4
,
ftensor4
,
dtensor4
,
itensor4
,
ltensor4
)
ctensor5
=
TensorType
(
'complex64'
,
((
False
,)
*
5
))
ztensor5
=
TensorType
(
'complex128'
,
((
False
,)
*
5
))
ftensor5
=
TensorType
(
'float32'
,
((
False
,)
*
5
))
dtensor5
=
TensorType
(
'float64'
,
((
False
,)
*
5
))
btensor5
=
TensorType
(
'int8'
,
((
False
,)
*
5
))
wtensor5
=
TensorType
(
'int16'
,
((
False
,)
*
5
))
itensor5
=
TensorType
(
'int32'
,
((
False
,)
*
5
))
ltensor5
=
TensorType
(
'int64'
,
((
False
,)
*
5
))
def
tensor5
(
name
=
None
,
dtype
=
None
):
"""Return a symbolic 5-D variable.
Parameters
----------
dtype: numeric type
None means to use theano.config.floatX.
name
A name to attach to this variable.
"""
if
dtype
is
None
:
dtype
=
config
.
floatX
type
=
TensorType
(
dtype
,
(
False
,
False
,
False
,
False
,
False
))
return
type
(
name
)
tensor5s
,
ftensor5s
,
dtensor5s
,
itensor5s
,
ltensor5s
=
_multi
(
tensor5
,
ftensor5
,
dtensor5
,
itensor5
,
ltensor5
)
Tensor
=
TensorType
Tensor
=
TensorType
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论