Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
ca677d9c
提交
ca677d9c
authored
9月 22, 2015
作者:
Xavier Bouthillier
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix stack interface use
上级
dfdcd682
隐藏空白字符变更
内嵌
并排
正在显示
4 个修改的文件
包含
20 行增加
和
20 行删除
+20
-20
sp.py
theano/sparse/sandbox/sp.py
+12
-12
neighbours.py
theano/tensor/nnet/neighbours.py
+2
-2
conv.py
theano/tensor/signal/conv.py
+2
-2
test_opt.py
theano/tensor/tests/test_opt.py
+4
-4
没有找到文件。
theano/sparse/sandbox/sp.py
浏览文件 @
ca677d9c
...
@@ -411,8 +411,8 @@ def convolve(kerns, kshp, nkern, images, imgshp, step=(1, 1), bias=None,
...
@@ -411,8 +411,8 @@ def convolve(kerns, kshp, nkern, images, imgshp, step=(1, 1), bias=None,
patches
=
(
sparse
.
structured_dot
(
csc
,
images
.
T
))
.
T
patches
=
(
sparse
.
structured_dot
(
csc
,
images
.
T
))
.
T
# compute output of linear classifier
# compute output of linear classifier
pshape
=
tensor
.
stack
(
images
.
shape
[
0
]
*
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
\
pshape
=
tensor
.
stack
(
[
images
.
shape
[
0
]
*
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
\
tensor
.
as_tensor
(
imgshp
[
0
]
*
kern_size
)
)
tensor
.
as_tensor
(
imgshp
[
0
]
*
kern_size
)]
)
patch_stack
=
tensor
.
reshape
(
patches
,
pshape
,
ndim
=
2
)
patch_stack
=
tensor
.
reshape
(
patches
,
pshape
,
ndim
=
2
)
# kern is of shape: nkern x ksize*number_of_input_features
# kern is of shape: nkern x ksize*number_of_input_features
...
@@ -425,9 +425,9 @@ def convolve(kerns, kshp, nkern, images, imgshp, step=(1, 1), bias=None,
...
@@ -425,9 +425,9 @@ def convolve(kerns, kshp, nkern, images, imgshp, step=(1, 1), bias=None,
# now to have feature maps in raster order ...
# now to have feature maps in raster order ...
# go from bsize*outshp x nkern to bsize x nkern*outshp
# go from bsize*outshp x nkern to bsize x nkern*outshp
newshp
=
tensor
.
stack
(
images
.
shape
[
0
],
\
newshp
=
tensor
.
stack
(
[
images
.
shape
[
0
],
\
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
\
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
\
tensor
.
as_tensor
(
nkern
)
)
tensor
.
as_tensor
(
nkern
)]
)
tensout
=
tensor
.
reshape
(
output
,
newshp
,
ndim
=
3
)
tensout
=
tensor
.
reshape
(
output
,
newshp
,
ndim
=
3
)
output
=
tensor
.
DimShuffle
((
False
,)
*
tensout
.
ndim
,
(
0
,
2
,
1
))(
tensout
)
output
=
tensor
.
DimShuffle
((
False
,)
*
tensout
.
ndim
,
(
0
,
2
,
1
))(
tensout
)
if
flatten
:
if
flatten
:
...
@@ -477,17 +477,17 @@ def max_pool(images, imgshp, maxpoolshp):
...
@@ -477,17 +477,17 @@ def max_pool(images, imgshp, maxpoolshp):
indptr
,
spmat_shape
)
indptr
,
spmat_shape
)
patches
=
sparse
.
structured_dot
(
csc
,
images
.
T
)
.
T
patches
=
sparse
.
structured_dot
(
csc
,
images
.
T
)
.
T
pshape
=
tensor
.
stack
(
images
.
shape
[
0
]
*
\
pshape
=
tensor
.
stack
(
[
images
.
shape
[
0
]
*
\
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
tensor
.
as_tensor
(
imgshp
[
0
]),
tensor
.
as_tensor
(
imgshp
[
0
]),
tensor
.
as_tensor
(
poolsize
)
)
tensor
.
as_tensor
(
poolsize
)]
)
patch_stack
=
tensor
.
reshape
(
patches
,
pshape
,
ndim
=
3
)
patch_stack
=
tensor
.
reshape
(
patches
,
pshape
,
ndim
=
3
)
out1
=
tensor
.
max
(
patch_stack
,
axis
=
2
)
out1
=
tensor
.
max
(
patch_stack
,
axis
=
2
)
pshape
=
tensor
.
stack
(
images
.
shape
[
0
],
pshape
=
tensor
.
stack
(
[
images
.
shape
[
0
],
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
tensor
.
as_tensor
(
N
.
prod
(
outshp
)),
tensor
.
as_tensor
(
imgshp
[
0
])
)
tensor
.
as_tensor
(
imgshp
[
0
])]
)
out2
=
tensor
.
reshape
(
out1
,
pshape
,
ndim
=
3
)
out2
=
tensor
.
reshape
(
out1
,
pshape
,
ndim
=
3
)
out3
=
tensor
.
DimShuffle
(
out2
.
broadcastable
,
(
0
,
2
,
1
))(
out2
)
out3
=
tensor
.
DimShuffle
(
out2
.
broadcastable
,
(
0
,
2
,
1
))(
out2
)
...
...
theano/tensor/nnet/neighbours.py
浏览文件 @
ca677d9c
...
@@ -569,8 +569,8 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
...
@@ -569,8 +569,8 @@ def neibs2images(neibs, neib_shape, original_shape, mode='valid'):
neib_shape
=
T
.
as_tensor_variable
(
neib_shape
)
neib_shape
=
T
.
as_tensor_variable
(
neib_shape
)
original_shape
=
T
.
as_tensor_variable
(
original_shape
)
original_shape
=
T
.
as_tensor_variable
(
original_shape
)
new_neib_shape
=
T
.
stack
(
original_shape
[
-
1
]
//
neib_shape
[
1
],
new_neib_shape
=
T
.
stack
(
[
original_shape
[
-
1
]
//
neib_shape
[
1
],
neib_shape
[
1
])
neib_shape
[
1
]
])
output_2d
=
images2neibs
(
neibs
.
dimshuffle
(
'x'
,
'x'
,
0
,
1
),
output_2d
=
images2neibs
(
neibs
.
dimshuffle
(
'x'
,
'x'
,
0
,
1
),
new_neib_shape
,
mode
=
mode
)
new_neib_shape
,
mode
=
mode
)
...
...
theano/tensor/signal/conv.py
浏览文件 @
ca677d9c
...
@@ -80,10 +80,10 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
...
@@ -80,10 +80,10 @@ def conv2d(input, filters, image_shape=None, filter_shape=None,
else
:
else
:
sym_nkern
=
1
sym_nkern
=
1
new_input_shape
=
tensor
.
join
(
0
,
tensor
.
stack
(
sym_bsize
,
1
),
input
.
shape
[
-
2
:])
new_input_shape
=
tensor
.
join
(
0
,
tensor
.
stack
(
[
sym_bsize
,
1
]
),
input
.
shape
[
-
2
:])
input4D
=
tensor
.
reshape
(
input
,
new_input_shape
,
ndim
=
4
)
input4D
=
tensor
.
reshape
(
input
,
new_input_shape
,
ndim
=
4
)
new_filter_shape
=
tensor
.
join
(
0
,
tensor
.
stack
(
sym_nkern
,
1
),
filters
.
shape
[
-
2
:])
new_filter_shape
=
tensor
.
join
(
0
,
tensor
.
stack
(
[
sym_nkern
,
1
]
),
filters
.
shape
[
-
2
:])
filters4D
=
tensor
.
reshape
(
filters
,
new_filter_shape
,
ndim
=
4
)
filters4D
=
tensor
.
reshape
(
filters
,
new_filter_shape
,
ndim
=
4
)
### perform actual convolution ###
### perform actual convolution ###
...
...
theano/tensor/tests/test_opt.py
浏览文件 @
ca677d9c
...
@@ -5118,7 +5118,7 @@ class T_local_reduce(unittest.TestCase):
...
@@ -5118,7 +5118,7 @@ class T_local_reduce(unittest.TestCase):
# on 32 bit systems
# on 32 bit systems
A
=
theano
.
shared
(
numpy
.
array
([
1
,
2
,
3
,
4
,
5
],
dtype
=
'int64'
))
A
=
theano
.
shared
(
numpy
.
array
([
1
,
2
,
3
,
4
,
5
],
dtype
=
'int64'
))
f
=
theano
.
function
([],
T
.
sum
(
T
.
stack
(
A
,
A
),
axis
=
0
),
mode
=
self
.
mode
)
f
=
theano
.
function
([],
T
.
sum
(
T
.
stack
(
[
A
,
A
]
),
axis
=
0
),
mode
=
self
.
mode
)
assert
numpy
.
allclose
(
f
(),
[
2
,
4
,
6
,
8
,
10
])
assert
numpy
.
allclose
(
f
(),
[
2
,
4
,
6
,
8
,
10
])
topo
=
f
.
maker
.
fgraph
.
toposort
()
topo
=
f
.
maker
.
fgraph
.
toposort
()
assert
isinstance
(
topo
[
-
1
]
.
op
,
T
.
Elemwise
)
assert
isinstance
(
topo
[
-
1
]
.
op
,
T
.
Elemwise
)
...
@@ -5127,7 +5127,7 @@ class T_local_reduce(unittest.TestCase):
...
@@ -5127,7 +5127,7 @@ class T_local_reduce(unittest.TestCase):
try
:
try
:
old
=
theano
.
config
.
warn
.
reduce_join
old
=
theano
.
config
.
warn
.
reduce_join
theano
.
config
.
warn
.
reduce_join
=
False
theano
.
config
.
warn
.
reduce_join
=
False
f
=
theano
.
function
([],
T
.
sum
(
T
.
stack
(
A
,
A
),
axis
=
1
),
f
=
theano
.
function
([],
T
.
sum
(
T
.
stack
(
[
A
,
A
]
),
axis
=
1
),
mode
=
self
.
mode
)
mode
=
self
.
mode
)
finally
:
finally
:
theano
.
config
.
warn
.
reduce_join
=
old
theano
.
config
.
warn
.
reduce_join
=
old
...
@@ -5454,7 +5454,7 @@ class TestMakeVector(utt.InferShapeTester):
...
@@ -5454,7 +5454,7 @@ class TestMakeVector(utt.InferShapeTester):
def
test_local_join_1
():
def
test_local_join_1
():
# test for vector
# test for vector
a
=
tensor
.
vector
(
'a'
)
a
=
tensor
.
vector
(
'a'
)
s
=
tensor
.
stack
(
a
)
s
=
tensor
.
stack
(
[
a
]
)
f
=
function
([
a
],
s
,
mode
=
mode_opt
)
f
=
function
([
a
],
s
,
mode
=
mode_opt
)
val
=
f
([
1
])
val
=
f
([
1
])
assert
numpy
.
all
(
val
==
[
1
])
assert
numpy
.
all
(
val
==
[
1
])
...
@@ -5520,7 +5520,7 @@ def test_local_join_empty():
...
@@ -5520,7 +5520,7 @@ def test_local_join_empty():
# test for vector, vector, empty to matrix
# test for vector, vector, empty to matrix
# We can't optimize this case.
# We can't optimize this case.
s
=
tensor
.
stack
(
a
,
a
,
empty_vec
)
s
=
tensor
.
stack
(
[
a
,
a
,
empty_vec
]
)
f
=
function
([
a
],
s
,
mode
=
mode_opt
)
f
=
function
([
a
],
s
,
mode
=
mode_opt
)
val
=
f
([])
val
=
f
([])
assert
numpy
.
all
(
val
==
[
1
])
assert
numpy
.
all
(
val
==
[
1
])
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论