Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
8036de32
提交
8036de32
authored
9月 30, 2011
作者:
David Warde-Farley
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #81 from delallea/deprecate_tensor_dot_shared
Deprecated tensor.shared (renamed tensor._shared)
上级
8cc83780
4572371c
显示空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
36 行增加
和
11 行删除
+36
-11
test_pfunc.py
theano/compile/tests/test_pfunc.py
+1
-1
test_neighbours.py
theano/sandbox/test_neighbours.py
+1
-1
test_rng_mrg.py
theano/sandbox/test_rng_mrg.py
+2
-2
test_scan.py
theano/scan_module/tests/test_scan.py
+1
-1
__init__.py
theano/tensor/__init__.py
+25
-1
basic.py
theano/tensor/basic.py
+1
-1
test_basic.py
theano/tensor/tests/test_basic.py
+4
-3
test_sharedvar.py
theano/tensor/tests/test_sharedvar.py
+1
-1
没有找到文件。
theano/compile/tests/test_pfunc.py
浏览文件 @
8036de32
...
@@ -645,7 +645,7 @@ class Test_aliasing_rules(unittest.TestCase):
...
@@ -645,7 +645,7 @@ class Test_aliasing_rules(unittest.TestCase):
"""
"""
def
shared
(
self
,
x
):
def
shared
(
self
,
x
):
return
tensor
.
shared
(
x
)
return
tensor
.
_
shared
(
x
)
def
test_shared_constructor_copies
(
self
):
def
test_shared_constructor_copies
(
self
):
# shared constructor makes copy
# shared constructor makes copy
...
...
theano/sandbox/test_neighbours.py
浏览文件 @
8036de32
...
@@ -333,7 +333,7 @@ def speed_neibs_wrap_centered():
...
@@ -333,7 +333,7 @@ def speed_neibs_wrap_centered():
def
test_neibs_grad
():
def
test_neibs_grad
():
shape
=
(
2
,
3
,
4
,
4
)
shape
=
(
2
,
3
,
4
,
4
)
images
=
T
.
shared
(
numpy
.
arange
(
numpy
.
prod
(
shape
),
dtype
=
'float32'
)
.
reshape
(
shape
))
images
=
shared
(
numpy
.
arange
(
numpy
.
prod
(
shape
),
dtype
=
'float32'
)
.
reshape
(
shape
))
cost
=
T
.
sum
(
T
.
sqr
(
images2neibs
(
images
,
(
2
,
2
))),
axis
=
[
0
,
1
])
cost
=
T
.
sum
(
T
.
sqr
(
images2neibs
(
images
,
(
2
,
2
))),
axis
=
[
0
,
1
])
...
...
theano/sandbox/test_rng_mrg.py
浏览文件 @
8036de32
...
@@ -113,7 +113,7 @@ def test_consistency_cpu_serial():
...
@@ -113,7 +113,7 @@ def test_consistency_cpu_serial():
for
i
in
range
(
n_streams
):
for
i
in
range
(
n_streams
):
stream_rstate
=
curr_rstate
.
copy
()
stream_rstate
=
curr_rstate
.
copy
()
for
j
in
range
(
n_substreams
):
for
j
in
range
(
n_substreams
):
rstate
=
t
ensor
.
shared
(
numpy
.
array
([
stream_rstate
.
copy
()],
dtype
=
'int32'
))
rstate
=
t
heano
.
shared
(
numpy
.
array
([
stream_rstate
.
copy
()],
dtype
=
'int32'
))
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
config
.
floatX
,
size
=
(
1
,))
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
config
.
floatX
,
size
=
(
1
,))
# Not really necessary, just mimicking rng_mrg.MRG_RandomStreams' behavior
# Not really necessary, just mimicking rng_mrg.MRG_RandomStreams' behavior
sample
.
rstate
=
rstate
sample
.
rstate
=
rstate
...
@@ -152,7 +152,7 @@ def test_consistency_cpu_parallel():
...
@@ -152,7 +152,7 @@ def test_consistency_cpu_parallel():
for
j
in
range
(
1
,
n_substreams
):
for
j
in
range
(
1
,
n_substreams
):
rstate
.
append
(
rng_mrg
.
ff_2p72
(
rstate
[
-
1
]))
rstate
.
append
(
rng_mrg
.
ff_2p72
(
rstate
[
-
1
]))
rstate
=
numpy
.
asarray
(
rstate
)
rstate
=
numpy
.
asarray
(
rstate
)
rstate
=
t
ensor
.
shared
(
rstate
)
rstate
=
t
heano
.
shared
(
rstate
)
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
new_rstate
,
sample
=
rng_mrg
.
mrg_uniform
.
new
(
rstate
,
ndim
=
None
,
dtype
=
config
.
floatX
,
size
=
(
n_substreams
,))
dtype
=
config
.
floatX
,
size
=
(
n_substreams
,))
...
...
theano/scan_module/tests/test_scan.py
浏览文件 @
8036de32
...
@@ -2597,7 +2597,7 @@ def test_speed():
...
@@ -2597,7 +2597,7 @@ def test_speed():
if
1
:
if
1
:
r
=
numpy
.
arange
(
10000
)
.
astype
(
theano
.
config
.
floatX
)
.
reshape
(
-
1
,
10
)
r
=
numpy
.
arange
(
10000
)
.
astype
(
theano
.
config
.
floatX
)
.
reshape
(
-
1
,
10
)
shared_r
=
theano
.
shared
(
r
)
shared_r
=
theano
.
shared
(
r
)
s_i
=
t
ensor
.
shared
(
numpy
.
array
(
1
))
s_i
=
t
heano
.
shared
(
numpy
.
array
(
1
))
s_rinc
=
tensor
.
inc_subtensor
(
shared_r
[
s_i
],
shared_r
[
s_i
-
1
],
s_rinc
=
tensor
.
inc_subtensor
(
shared_r
[
s_i
],
shared_r
[
s_i
-
1
],
tolerate_inplace_aliasing
=
True
)
tolerate_inplace_aliasing
=
True
)
theano
.
printing
.
debugprint
(
s_rinc
)
theano
.
printing
.
debugprint
(
s_rinc
)
...
...
theano/tensor/__init__.py
浏览文件 @
8036de32
"""Define the tensor toplevel"""
"""Define the tensor toplevel"""
__docformat__
=
"restructuredtext en"
__docformat__
=
"restructuredtext en"
import
warnings
from
basic
import
*
from
basic
import
*
import
opt
import
opt
...
@@ -21,7 +24,28 @@ from elemwise import \
...
@@ -21,7 +24,28 @@ from elemwise import \
DimShuffle
,
Elemwise
,
CAReduce
DimShuffle
,
Elemwise
,
CAReduce
import
sharedvar
# adds shared-variable constructors
import
sharedvar
# adds shared-variable constructors
from
sharedvar
import
tensor_constructor
as
shared
# We import as `_shared` instead of `shared` to avoid confusion between
# `theano.shared` and `tensor._shared`.
from
sharedvar
import
tensor_constructor
as
_shared
def
shared
(
*
args
,
**
kw
):
"""
Backward-compatibility wrapper around `tensor._shared`.
Once the deprecation warning has been around for long enough, this function
can be deleted.
"""
# Note that we do not use the DeprecationWarning class because it is
# ignored by default since python 2.7.
warnings
.
warn
(
'`tensor.shared` is deprecated. You should probably be using'
' `theano.shared` instead (if you *really* intend to call '
'`tensor.shared`, you can get rid of this warning by using '
'`tensor._shared`).'
,
stacklevel
=
2
)
return
_shared
(
*
args
,
**
kw
)
import
nnet
# used for softmax, sigmoid, etc.
import
nnet
# used for softmax, sigmoid, etc.
...
...
theano/tensor/basic.py
浏览文件 @
8036de32
...
@@ -12,7 +12,7 @@ from itertools import izip
...
@@ -12,7 +12,7 @@ from itertools import izip
import
numpy
,
theano
import
numpy
,
theano
#from copy import copy as python_copy
#from copy import copy as python_copy
from
theano
import
gof
,
shared
from
theano
import
gof
from
theano.gof
import
Apply
,
Constant
,
Op
,
Type
,
Value
,
Variable
from
theano.gof
import
Apply
,
Constant
,
Op
,
Type
,
Value
,
Variable
...
...
theano/tensor/tests/test_basic.py
浏览文件 @
8036de32
...
@@ -10,6 +10,7 @@ from numpy.testing import dec
...
@@ -10,6 +10,7 @@ from numpy.testing import dec
from
numpy.testing.noseclasses
import
KnownFailureTest
from
numpy.testing.noseclasses
import
KnownFailureTest
from
theano.tensor
import
*
from
theano.tensor
import
*
from
theano.tensor
import
_shared
from
theano.tensor
import
basic
as
tensor
# for hidden symbols
from
theano.tensor
import
basic
as
tensor
# for hidden symbols
from
theano.tensor
import
inplace
from
theano.tensor
import
inplace
...
@@ -1796,7 +1797,7 @@ class T_subtensor(unittest.TestCase):
...
@@ -1796,7 +1797,7 @@ class T_subtensor(unittest.TestCase):
"""
"""
This is build in a way that allow to reuse it to test the equivalent gpu op.
This is build in a way that allow to reuse it to test the equivalent gpu op.
"""
"""
def
__init__
(
self
,
name
,
shared
=
shared
,
def
__init__
(
self
,
name
,
shared
=
_
shared
,
sub
=
theano
.
tensor
.
basic
.
Subtensor
,
sub
=
theano
.
tensor
.
basic
.
Subtensor
,
inc_sub
=
theano
.
tensor
.
basic
.
IncSubtensor
,
inc_sub
=
theano
.
tensor
.
basic
.
IncSubtensor
,
adv_sub1
=
theano
.
tensor
.
basic
.
AdvancedSubtensor1
,
adv_sub1
=
theano
.
tensor
.
basic
.
AdvancedSubtensor1
,
...
@@ -2361,7 +2362,7 @@ class T_subtensor(unittest.TestCase):
...
@@ -2361,7 +2362,7 @@ class T_subtensor(unittest.TestCase):
for
idx
in
idxs
:
for
idx
in
idxs
:
# Should stay on the cpu.
# Should stay on the cpu.
idx_
=
shared
(
numpy
.
asarray
(
idx
))
idx_
=
_
shared
(
numpy
.
asarray
(
idx
))
t
=
n
[
idx_
]
t
=
n
[
idx_
]
gn
=
grad
(
sum
(
exp
(
t
)),
n
)
gn
=
grad
(
sum
(
exp
(
t
)),
n
)
f
=
function
([],
[
gn
,
gn
.
shape
],
mode
=
self
.
mode
)
f
=
function
([],
[
gn
,
gn
.
shape
],
mode
=
self
.
mode
)
...
@@ -5175,7 +5176,7 @@ class test_size(unittest.TestCase):
...
@@ -5175,7 +5176,7 @@ class test_size(unittest.TestCase):
def
test_shared
(
self
):
def
test_shared
(
self
):
# NB: we also test higher order tensors at the same time.
# NB: we also test higher order tensors at the same time.
y
=
numpy
.
zeros
((
1
,
2
,
3
,
4
),
dtype
=
config
.
floatX
)
y
=
numpy
.
zeros
((
1
,
2
,
3
,
4
),
dtype
=
config
.
floatX
)
x
=
t
ensor
.
shared
(
y
)
x
=
t
heano
.
shared
(
y
)
assert
y
.
size
==
function
([],
x
.
size
)()
assert
y
.
size
==
function
([],
x
.
size
)()
...
...
theano/tensor/tests/test_sharedvar.py
浏览文件 @
8036de32
...
@@ -622,7 +622,7 @@ def makeSharedTester(shared_constructor_,
...
@@ -622,7 +622,7 @@ def makeSharedTester(shared_constructor_,
return
SharedTester
return
SharedTester
test_shared_options
=
makeSharedTester
(
test_shared_options
=
makeSharedTester
(
shared_constructor_
=
tensor
.
shared
,
shared_constructor_
=
tensor
.
_
shared
,
dtype_
=
theano
.
config
.
floatX
,
dtype_
=
theano
.
config
.
floatX
,
get_value_borrow_true_alias_
=
True
,
get_value_borrow_true_alias_
=
True
,
shared_borrow_true_alias_
=
True
,
shared_borrow_true_alias_
=
True
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论