Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6cf8a013
提交
6cf8a013
authored
5月 21, 2015
作者:
abergeron
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #2926 from nouiz/mixed
Mixed
上级
6a93ccc7
81e7a293
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
71 行增加
和
28 行删除
+71
-28
numpy.txt
doc/tutorial/numpy.txt
+1
-0
configparser.py
theano/configparser.py
+31
-0
cmodule.py
theano/gof/cmodule.py
+7
-9
link.py
theano/gof/link.py
+10
-5
__init__.py
theano/sandbox/cuda/__init__.py
+4
-4
dnn.py
theano/sandbox/cuda/dnn.py
+2
-2
test_blas.py
theano/sandbox/cuda/tests/test_blas.py
+1
-1
test_memory.py
theano/sandbox/cuda/tests/test_memory.py
+1
-0
__init__.py
theano/sandbox/gpuarray/__init__.py
+1
-1
basic_ops.py
theano/sandbox/gpuarray/basic_ops.py
+3
-2
nnet.py
theano/tensor/nnet/nnet.py
+5
-3
test_type_other.py
theano/tensor/tests/test_type_other.py
+5
-1
没有找到文件。
doc/tutorial/numpy.txt
浏览文件 @
6cf8a013
...
...
@@ -11,6 +11,7 @@ Here are some quick guides to NumPy:
* `Numpy User Guide <http://docs.scipy.org/doc/numpy/user/index.html>`__
* `More detailed Numpy tutorial <http://www.scipy.org/Tentative_NumPy_Tutorial>`__
* `100 NumPy exercises <https://github.com/rougier/numpy-100>`__
* `Numpy tutorial <http://www.labri.fr/perso/nrougier/teaching/numpy/numpy.html>`__
.. [TODO: More doc, e.g. see _test_tensor.py]
...
...
theano/configparser.py
浏览文件 @
6cf8a013
...
...
@@ -89,6 +89,37 @@ theano_raw_cfg = ConfigParser.RawConfigParser()
theano_raw_cfg
.
read
(
config_files
)
def
change_flags
(
**
kwargs
):
"""
Use this as a decorator to change the value of Theano config variable.
Useful during tests.
"""
def
change_flags_exec
(
f
):
def
inner
(
*
args
,
**
kwargs_
):
old_val
=
{}
for
k
in
kwargs
:
l
=
[
v
for
v
in
theano
.
configparser
.
_config_var_list
if
v
.
fullname
==
k
]
assert
len
(
l
)
==
1
old_val
[
k
]
=
l
[
0
]
.
__get__
()
try
:
for
k
in
kwargs
:
l
=
[
v
for
v
in
theano
.
configparser
.
_config_var_list
if
v
.
fullname
==
k
]
assert
len
(
l
)
==
1
l
[
0
]
.
__set__
(
None
,
kwargs
[
k
])
return
f
(
*
args
,
**
kwargs_
)
finally
:
for
k
in
kwargs
:
l
=
[
v
for
v
in
theano
.
configparser
.
_config_var_list
if
v
.
fullname
==
k
]
assert
len
(
l
)
==
1
l
[
0
]
.
__set__
(
None
,
old_val
[
k
])
return
inner
return
change_flags_exec
def
fetch_val_for_key
(
key
):
"""Return the overriding config value for a key.
A successful search returns a string value.
...
...
theano/gof/cmodule.py
浏览文件 @
6cf8a013
...
...
@@ -4,7 +4,6 @@ from __future__ import print_function
import
atexit
import
cPickle
import
logging
import
operator
import
os
import
re
import
shutil
...
...
@@ -25,12 +24,12 @@ except ImportError:
import
numpy.distutils
# TODO: TensorType should handle this
import
theano
from
theano.compat
import
PY3
,
next
,
decode
,
decode_iter
from
theano.compat
import
PY3
,
decode
,
decode_iter
from
theano.compat.six
import
b
,
BytesIO
,
StringIO
from
theano.gof.utils
import
flatten
from
theano.configparser
import
config
from
theano.gof.cc
import
hash_from_code
from
theano.misc.windows
import
(
subprocess_Popen
,
call_subprocess_Popen
,
from
theano.misc.windows
import
(
subprocess_Popen
,
output_subprocess_Popen
)
# we will abuse the lockfile mechanism when reading and writing the registry
...
...
@@ -846,14 +845,15 @@ class ModuleCache(object):
get_safe_part
(
key
),
[])
.
append
(
key
)
else
:
dir1
=
os
.
path
.
dirname
(
self
.
entry_from_key
[
key
])
dir2
=
os
.
path
.
dirname
(
entry
)
_logger
.
warning
(
"The same cache key is associated to "
"different modules (
%
s and
%
s). This "
"is not supposed to happen! You may "
"need to manually delete your cache "
"directory to fix this."
,
self
.
entry_from_key
[
key
],
entry
)
dir1
,
dir2
)
# Clean up the name space to prevent bug.
if
key_data
.
keys
:
del
key
...
...
@@ -1050,8 +1050,6 @@ class ModuleCache(object):
if
module
is
not
None
:
return
module
lock_taken
=
False
src_code
=
lnk
.
get_src_code
()
# Is the source code already in the cache?
module_hash
=
get_module_hash
(
src_code
,
key
)
...
...
@@ -1498,8 +1496,8 @@ def std_lib_dirs_and_libs():
r'EGG-INFO\mingw\usr\x86_64-w64-mingw32\lib'
)]
for
f
,
lib
in
[(
'libmsvcr90.a'
,
'mingw 4.5.2 or 4.8.1-2 (newer could work)'
)]:
if
not
any
([
os
.
path
.
exists
(
os
.
path
.
join
(
libdir
,
f
))
for
libdir
in
libdirs
]):
if
not
any
([
os
.
path
.
exists
(
os
.
path
.
join
(
tmp_
libdir
,
f
))
for
tmp_
libdir
in
libdirs
]):
print
((
"Your Python version is from Canopy. "
+
"You need to install the package '"
+
lib
+
"' from Canopy package manager."
...
...
theano/gof/link.py
浏览文件 @
6cf8a013
...
...
@@ -110,13 +110,17 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
trace
=
()
exc_value
.
__thunk_trace__
=
trace
exc_value
.
__op_instance__
=
node
if
node
in
node
.
fgraph
.
toposort
():
exc_value
.
__applynode_index__
=
node
.
fgraph
.
toposort
()
.
index
(
node
)
topo
=
node
.
fgraph
.
toposort
()
if
node
in
topo
:
node_index
=
topo
.
index
(
node
)
else
:
exc_value
.
__applynode_index__
=
None
node_index
=
None
exc_value
.
__applynode_index__
=
node_index
hints
=
[]
detailed_err_msg
=
"
\n
Apply node that caused the error: "
+
str
(
node
)
if
exc_value
.
__applynode_index__
is
not
None
:
detailed_err_msg
+=
"
\n
Toposort index:
%
d"
%
node_index
types
=
[
getattr
(
ipt
,
'type'
,
'No type'
)
for
ipt
in
node
.
inputs
]
detailed_err_msg
+=
"
\n
Inputs types:
%
s
\n
"
%
types
...
...
@@ -137,10 +141,11 @@ def raise_with_op(node, thunk=None, exc_info=None, storage_map=None):
shapes
=
"The thunk don't have an inputs attributes."
strides
=
"So we can't access the strides of inputs values"
scalar_values
=
"And can't print its inputs scalar value"
clients
=
[[
c
[
0
]
for
c
in
var
.
clients
]
for
var
in
node
.
outputs
]
detailed_err_msg
+=
(
"Inputs shapes:
%
s"
%
shapes
+
"
\n
Inputs strides:
%
s"
%
strides
+
"
\n
Inputs values:
%
s
\n
"
%
scalar_values
)
"
\n
Inputs values:
%
s"
%
scalar_values
+
"
\n
Outputs clients:
%
s
\n
"
%
clients
)
else
:
hints
.
append
(
"HINT: Use another linker then the c linker to"
...
...
theano/sandbox/cuda/__init__.py
浏览文件 @
6cf8a013
...
...
@@ -436,13 +436,13 @@ def use(device,
cuda_enabled
=
True
if
default_to_move_computation_to_gpu
:
# Do not add inplace tag here. We do not want to
# enable/disable gpu opt based on the inplace tag.
optdb
.
add_tags
(
'gpu_opt'
,
'fast_compile'
,
'fast_run'
,
'inplace'
)
'fast_run'
)
optdb
.
add_tags
(
'gpu_after_fusion'
,
'fast_run'
,
'inplace'
)
'fast_run'
)
if
force
:
try
:
...
...
theano/sandbox/cuda/dnn.py
浏览文件 @
6cf8a013
...
...
@@ -1672,6 +1672,8 @@ if True:
if
not
dnn_available
():
return
if
isinstance
(
node
.
op
,
DownsampleFactorMaxGrad
):
if
not
node
.
op
.
ignore_border
:
return
inp
,
out
,
inp_grad
=
node
.
inputs
ds
=
node
.
op
.
ds
st
=
node
.
op
.
st
...
...
@@ -1683,8 +1685,6 @@ if True:
(
inp_grad
.
owner
and
isinstance
(
inp_grad
.
owner
.
op
,
HostFromGpu
))):
desc
=
GpuDnnPoolDesc
(
ws
=
ds
,
stride
=
st
,
mode
=
mode
,
pad
=
pad
)()
if
not
node
.
op
.
ignore_border
:
return
ret
=
GpuDnnPoolGrad
()(
gpu_contiguous
(
inp
),
gpu_contiguous
(
out
),
gpu_contiguous
(
inp_grad
),
...
...
theano/sandbox/cuda/tests/test_blas.py
浏览文件 @
6cf8a013
...
...
@@ -90,7 +90,7 @@ def test_dot22scalar():
[
a
,
b
],
tensor
.
dot
(
a
,
b
)
*
numpy
.
asarray
(
4
,
'float32'
))
t
=
f
.
maker
.
fgraph
.
toposort
()
assert
len
(
t
)
==
4
assert
len
(
t
)
==
4
,
t
assert
isinstance
(
t
[
0
]
.
op
,
tcn
.
GpuFromHost
)
assert
isinstance
(
t
[
1
]
.
op
,
tcn
.
GpuFromHost
)
assert
isinstance
(
t
[
2
]
.
op
,
tcn
.
blas
.
GpuDot22Scalar
)
...
...
theano/sandbox/cuda/tests/test_memory.py
浏览文件 @
6cf8a013
...
...
@@ -122,6 +122,7 @@ def test_memory():
assert
mem1
==
freemem
(),
(
mem1
,
freemem
())
@theano.configparser.change_flags
(
**
{
'vm.lazy'
:
True
})
def
test_memory_lazy
():
"""As test_memory, but with the ifelse op.
...
...
theano/sandbox/gpuarray/__init__.py
浏览文件 @
6cf8a013
...
...
@@ -56,7 +56,7 @@ if pygpu:
init_dev
(
config
.
device
)
import
theano.compile
theano
.
compile
.
shared_constructor
(
gpuarray_shared_constructor
)
optdb
.
add_tags
(
'gpuarray_opt'
,
'fast_run'
,
'fast_compile'
,
'inplace'
)
optdb
.
add_tags
(
'gpuarray_opt'
,
'fast_run'
,
'fast_compile'
)
elif
config
.
gpuarray
.
init_device
!=
''
:
init_dev
(
config
.
gpuarray
.
init_device
)
...
...
theano/sandbox/gpuarray/basic_ops.py
浏览文件 @
6cf8a013
...
...
@@ -727,8 +727,9 @@ class GpuAllocEmpty(HideC, Alloc):
def
make_node
(
self
,
*
shape
):
sh
,
bcast
=
self
.
validate_shape
(
shape
)
otype
=
GpuArrayType
(
dtype
=
self
.
dtype
,
broadcastable
=
bcast
)
return
Apply
(
self
,
sh
,
[
otype
()])
output
=
GpuArrayType
(
dtype
=
self
.
dtype
,
broadcastable
=
bcast
)()
output
.
tag
.
values_eq_approx
=
tensor
.
type
.
values_eq_approx_always_true
return
Apply
(
self
,
sh
,
[
output
])
def
perform
(
self
,
node
,
inputs
,
out_
):
out
=
out_
[
0
]
...
...
theano/tensor/nnet/nnet.py
浏览文件 @
6cf8a013
...
...
@@ -16,7 +16,7 @@ import theano
from
theano
import
gof
from
theano.tensor
import
basic
as
tensor
from
theano.tensor
import
subtensor
from
theano.tensor
import
elemwise
,
dmatrix
,
fmatrix
,
dvector
,
fvector
from
theano.tensor
import
elemwise
from
theano.tensor
import
opt
from
theano.compile
import
optdb
from
theano.gof
import
Apply
...
...
@@ -1426,9 +1426,11 @@ optdb.register('crossentropy_to_crossentropy_with_softmax',
'fast_run'
,
'xent'
,
'fast_compile_gpu'
)
@opt.register_specialize
(
'fast_compile_gpu'
)
@opt.register_specialize
(
'fast_compile_gpu'
,
'local_crossentropy_to_crossentropy_with_softmax_grad'
)
# old name
@gof.local_optimizer
([
softmax_grad
])
def
local_
crossentropy
_to_crossentropy_with_softmax_grad
(
node
):
def
local_
softmax_grad
_to_crossentropy_with_softmax_grad
(
node
):
if
node
.
op
==
softmax_grad
:
g_coding_dist
,
coding_dist
=
node
.
inputs
if
(
g_coding_dist
.
owner
and
...
...
theano/tensor/tests/test_type_other.py
浏览文件 @
6cf8a013
...
...
@@ -35,5 +35,9 @@ def test_none_Constant():
x
=
tensor
.
vector
(
'x'
)
y
=
tensor
.
argmax
(
x
)
f
=
theano
.
function
([
x
],
[
y
])
kwargs
=
{}
# We can't pickle DebugMode
if
theano
.
config
.
mode
in
[
"DebugMode"
,
"DEBUG_MODE"
]:
kwargs
=
{
'mode'
:
'FAST_RUN'
}
f
=
theano
.
function
([
x
],
[
y
],
**
kwargs
)
cPickle
.
loads
(
cPickle
.
dumps
(
f
))
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论