Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
f128a6d5
提交
f128a6d5
authored
1月 20, 2010
作者:
Pascal Lamblin
浏览文件
操作
浏览文件
下载
差异文件
merge
上级
3a038b3e
668f41e0
隐藏空白字符变更
内嵌
并排
正在显示
12 个修改的文件
包含
115 行增加
和
69 行删除
+115
-69
index.txt
doc/index.txt
+2
-3
install.txt
doc/install.txt
+5
-2
dev_start_guide.txt
doc/internal/dev_start_guide.txt
+0
-3
basic.txt
doc/library/tensor/basic.txt
+2
-0
links.txt
doc/links.txt
+2
-2
symbolic_graphs.txt
doc/tutorial/symbolic_graphs.txt
+1
-1
__init__.py
theano/sandbox/cuda/__init__.py
+74
-44
nvcc_compiler.py
theano/sandbox/cuda/nvcc_compiler.py
+9
-0
opt.py
theano/tensor/opt.py
+5
-3
raw_random.py
theano/tensor/raw_random.py
+3
-1
sharedvar.py
theano/tensor/sharedvar.py
+7
-5
test_randomstreams.py
theano/tensor/tests/test_randomstreams.py
+5
-5
没有找到文件。
doc/index.txt
浏览文件 @
f128a6d5
...
@@ -36,6 +36,7 @@ Roughly in order of what you'll want to check out:
...
@@ -36,6 +36,7 @@ Roughly in order of what you'll want to check out:
* :ref:`libdoc` -- All Theano's functionality, module by module.
* :ref:`libdoc` -- All Theano's functionality, module by module.
* :ref:`extending` -- Learn to add a Type, Op, or graph optimization.
* :ref:`extending` -- Learn to add a Type, Op, or graph optimization.
* :ref:`internal` -- How to maintaining Theano, LISA-specific tips, and more...
* :ref:`internal` -- How to maintaining Theano, LISA-specific tips, and more...
* `API <api/>`_ -- The automatically-generated API
You can download the latest `PDF documentation <http://deeplearning.net/theanodoc/theano.pdf>`_, rather than reading it online.
You can download the latest `PDF documentation <http://deeplearning.net/theanodoc/theano.pdf>`_, rather than reading it online.
...
@@ -46,7 +47,7 @@ Community
...
@@ -46,7 +47,7 @@ Community
* Register and post to `theano-dev`_ if you want to talk to the developers.
* Register and post to `theano-dev`_ if you want to talk to the developers.
* We try to stay organized with `Theano's Trac <
trac/
>`__
* We try to stay organized with `Theano's Trac <
http://trac-hg.assembla.com/theano/report/1
>`__
* Come visit us in Montreal! Most of the developers are students in the LISA_ group at the `University of Montreal`_.
* Come visit us in Montreal! Most of the developers are students in the LISA_ group at the `University of Montreal`_.
...
@@ -68,8 +69,6 @@ Community
...
@@ -68,8 +69,6 @@ Community
LICENSE
LICENSE
.. _theano-dev: http://groups.google.com/group/theano-dev
.. _theano-dev: http://groups.google.com/group/theano-dev
.. _theano-users: http://groups.google.com/group/theano-users
.. _theano-users: http://groups.google.com/group/theano-users
.. _tickets: http://pylearn.org/theano/trac/query?status=accepted&status=assigned&status=new&status=reopened&group=milestone&max=200&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=component&col=time&report=9&order=priority
.. _tickets: http://pylearn.org/theano/trac/query?status=accepted&status=assigned&status=new&status=reopened&group=milestone&max=200&col=id&col=summary&col=status&col=owner&col=type&col=priority&col=component&col=time&report=9&order=priority
...
...
doc/install.txt
浏览文件 @
f128a6d5
...
@@ -278,8 +278,11 @@ but this has not been tested yet.
...
@@ -278,8 +278,11 @@ but this has not been tested yet.
``export PYTHONPATH=PYTHONPATH:$HOME/Theano``.
``export PYTHONPATH=PYTHONPATH:$HOME/Theano``.
- Please note that at this time, some tests (launched using ``nosetests``) are
- Please note that at this time, some tests (launched using ``nosetests``) are
still failing under Windows.
still failing under Windows: we are working on fixing them.
We are working on fixing them.
It may also happen that many tests may fail while running the test-suite,
due to insufficient memory resources: one workaround is to run nosetests
multiple times under individual subdirectories.
Generating the documentation
Generating the documentation
----------------------------
----------------------------
...
...
doc/internal/dev_start_guide.txt
浏览文件 @
f128a6d5
...
@@ -119,9 +119,6 @@ to your ``Theano`` folder and execute the following command:
...
@@ -119,9 +119,6 @@ to your ``Theano`` folder and execute the following command:
hg pull -u
hg pull -u
You may also download the latest source directly as a gzip'd tar file:
`<http://pylearn.org/hg/Theano/archive/tip.tar.gz>`__.
Nightly test
Nightly test
============
============
...
...
doc/library/tensor/basic.txt
浏览文件 @
f128a6d5
...
@@ -331,6 +331,8 @@ Indexing
...
@@ -331,6 +331,8 @@ Indexing
Basic indexing.
Basic indexing.
Mirrors numpy's `basic indexing <http://docs.scipy.org/doc/numpy/reference/arrays.indexing.html>`_. Read that page first.
Advanced indexing.
Advanced indexing.
.. _libdoc_tensor_elementwise:
.. _libdoc_tensor_elementwise:
...
...
doc/links.txt
浏览文件 @
f128a6d5
...
@@ -40,10 +40,10 @@ This is a sort of memo for developers and would-be developers.
...
@@ -40,10 +40,10 @@ This is a sort of memo for developers and would-be developers.
.. _mercurial: http://www.selenic.com/mercurial/wiki/
.. _mercurial: http://www.selenic.com/mercurial/wiki/
.. _nosetests: http://somethingaboutorange.com/mrl/projects/nose/
.. _nosetests: http://somethingaboutorange.com/mrl/projects/nose/
.. _numpy: http://numpy.scipy.org/
.. _numpy: http://numpy.scipy.org/
.. _python: http://www.python.or
.. _python: http://www.python.or
g
.. _scipy: http://scipy.org/
.. _scipy: http://scipy.org/
.. _autodiff: http://autodiff.org
.. _autodiff: http://
www.
autodiff.org
.. _boost.python: http://www.boost.org/doc/libs/1_38_0/libs/python/doc/index.html
.. _boost.python: http://www.boost.org/doc/libs/1_38_0/libs/python/doc/index.html
.. _cython: http://www.cython.org/
.. _cython: http://www.cython.org/
.. _liboil: http://liboil.freedesktop.org/wiki/
.. _liboil: http://liboil.freedesktop.org/wiki/
...
...
doc/tutorial/symbolic_graphs.txt
浏览文件 @
f128a6d5
...
@@ -105,7 +105,7 @@ how to compute the gradient of the node's outputs with respect to its
...
@@ -105,7 +105,7 @@ how to compute the gradient of the node's outputs with respect to its
inputs. Note that if an :ref:`op` does not provide this information,
inputs. Note that if an :ref:`op` does not provide this information,
it is assumed that the gradient does not defined.
it is assumed that the gradient does not defined.
Using the
Using the
`chain rule <http://en.wikipedia.org/wiki/Chain_r
i
le>`_
`chain rule <http://en.wikipedia.org/wiki/Chain_r
u
le>`_
these gradients can be composed in order to obtain the expression of the
these gradients can be composed in order to obtain the expression of the
gradient of the graph's output with respect to the graph's inputs .
gradient of the graph's output with respect to the graph's inputs .
...
...
theano/sandbox/cuda/__init__.py
浏览文件 @
f128a6d5
import
os
,
sys
import
os
,
sys
from
theano.gof.compiledir
import
get_compiledir
from
theano.gof.compiledir
import
get_compiledir
from
theano.compile
import
optdb
from
theano.compile
import
optdb
import
theano.config
as
config
import
logging
,
copy
import
logging
,
copy
_logger_name
=
'theano_cuda_ndarray'
_logger_name
=
'theano_cuda_ndarray'
...
@@ -15,8 +16,34 @@ def debug(*msg):
...
@@ -15,8 +16,34 @@ def debug(*msg):
_logger
.
debug
(
_logger_name
+
'DEBUG: '
+
' '
.
join
(
str
(
m
)
for
m
in
msg
))
_logger
.
debug
(
_logger_name
+
'DEBUG: '
+
' '
.
join
(
str
(
m
)
for
m
in
msg
))
#compile type_support.cu
# Compile type_support.cu
#this need that nvcc(part of cuda) is installed
# This need that nvcc (part of cuda) is installed. If it is not, a warning is
# printed and this module will not be working properly (we set `enable_cuda`
# to False).
# This variable is True by default, and set to False if something goes wrong
# when trying to initialize cuda.
enable_cuda
=
True
# Global variable to avoid displaying the same warning multiple times.
cuda_warning_is_displayed
=
False
# Code factorized within a function so that it may be called from multiple
# places (which is not currently the case, but may be useful in the future).
def
set_cuda_disabled
():
"""Function used to disable cuda.
A warning is displayed, so that the user is aware that cuda-based code is
not going to work.
Note that there is no point calling this function from outside of
`cuda.__init__`, since it has no effect once the module is loaded.
"""
global
enable_cuda
,
cuda_warning_is_displayed
enable_cuda
=
False
if
not
cuda_warning_is_displayed
:
cuda_warning_is_displayed
=
True
warning
(
'Cuda is disabled, cuda-based code will thus not be '
'working properly'
)
old_file
=
os
.
path
.
join
(
os
.
path
.
split
(
__file__
)[
0
],
'type_support.so'
)
old_file
=
os
.
path
.
join
(
os
.
path
.
split
(
__file__
)[
0
],
'type_support.so'
)
if
os
.
path
.
exists
(
old_file
):
if
os
.
path
.
exists
(
old_file
):
...
@@ -30,55 +57,58 @@ except ImportError:
...
@@ -30,55 +57,58 @@ except ImportError:
import
nvcc_compiler
import
nvcc_compiler
print
__file__
if
not
nvcc_compiler
.
is_nvcc_available
():
set_cuda_disabled
()
cuda_path
=
os
.
path
.
split
(
old_file
)[
0
]
if
enable_cuda
:
code
=
open
(
os
.
path
.
join
(
cuda_path
,
"type_support.cu"
))
.
read
()
print
__file__
loc
=
os
.
path
.
join
(
get_compiledir
(),
'type_support'
)
cuda_path
=
os
.
path
.
split
(
old_file
)[
0
]
if
not
os
.
path
.
exists
(
loc
):
code
=
open
(
os
.
path
.
join
(
cuda_path
,
"type_support.cu"
))
.
read
()
os
.
makedirs
(
loc
)
loc
=
os
.
path
.
join
(
get_compiledir
(),
'type_support'
)
if
not
os
.
path
.
exists
(
loc
):
os
.
makedirs
(
loc
)
CUDA_NDARRAY
=
os
.
getenv
(
'CUDA_NDARRAY'
)
CUDA_NDARRAY
=
os
.
getenv
(
'CUDA_NDARRAY'
)
include_dirs
=
[]
include_dirs
=
[]
lib_dirs
=
[]
lib_dirs
=
[]
if
CUDA_NDARRAY
:
if
CUDA_NDARRAY
:
include_dirs
.
append
(
CUDA_NDARRAY
)
include_dirs
.
append
(
CUDA_NDARRAY
)
lib_dirs
.
append
(
CUDA_NDARRAY
)
lib_dirs
.
append
(
CUDA_NDARRAY
)
else
:
import
theano.sandbox
path
=
os
.
path
.
split
(
os
.
path
.
split
(
os
.
path
.
split
(
theano
.
sandbox
.
__file__
)[
0
])[
0
])[
0
]
path2
=
os
.
path
.
join
(
path
,
'cuda_ndarray'
)
if
os
.
path
.
isdir
(
path2
):
include_dirs
.
append
(
path2
)
lib_dirs
.
append
(
path2
)
else
:
else
:
path
=
os
.
path
.
split
(
path
)[
0
]
import
theano.sandbox
path
=
os
.
path
.
split
(
os
.
path
.
split
(
os
.
path
.
split
(
theano
.
sandbox
.
__file__
)[
0
])[
0
])[
0
]
path2
=
os
.
path
.
join
(
path
,
'cuda_ndarray'
)
path2
=
os
.
path
.
join
(
path
,
'cuda_ndarray'
)
include_dirs
.
append
(
path2
)
if
os
.
path
.
isdir
(
path2
):
lib_dirs
.
append
(
path2
)
include_dirs
.
append
(
path2
)
lib_dirs
.
append
(
path2
)
else
:
path
=
os
.
path
.
split
(
path
)[
0
]
path2
=
os
.
path
.
join
(
path
,
'cuda_ndarray'
)
include_dirs
.
append
(
path2
)
lib_dirs
.
append
(
path2
)
nvcc_compiler
.
nvcc_module_compile_str
(
'type_support'
,
code
,
location
=
loc
,
include_dirs
=
include_dirs
,
lib_dirs
=
lib_dirs
,
libs
=
[
'cuda_ndarray'
])
from
type_support.type_support
import
*
if
enable_cuda
:
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda.var
import
(
CudaNdarrayVariable
,
CudaNdarrayConstant
,
CudaNdarraySharedVariable
,
shared_constructor
)
import
basic_ops
from
basic_ops
import
(
GpuFromHost
,
HostFromGpu
,
GpuElemwise
,
GpuDimShuffle
,
GpuSum
,
GpuReshape
,
GpuSubtensor
,
GpuIncSubtensor
,
GpuFlatten
,
GpuShape
)
import
opt
import
cuda_ndarray
nvcc_compiler
.
nvcc_module_compile_str
(
'type_support'
,
code
,
location
=
loc
,
include_dirs
=
include_dirs
,
lib_dirs
=
lib_dirs
,
libs
=
[
'cuda_ndarray'
])
from
type_support.type_support
import
*
from
theano.sandbox.cuda.type
import
CudaNdarrayType
from
theano.sandbox.cuda.var
import
(
CudaNdarrayVariable
,
CudaNdarrayConstant
,
CudaNdarraySharedVariable
,
shared_constructor
)
import
basic_ops
from
basic_ops
import
(
GpuFromHost
,
HostFromGpu
,
GpuElemwise
,
GpuDimShuffle
,
GpuSum
,
GpuReshape
,
GpuSubtensor
,
GpuIncSubtensor
,
GpuFlatten
,
GpuShape
)
import
opt
import
cuda_ndarray
import
theano.config
as
config
def
use
(
device
=
config
.
THEANO_GPU
):
def
use
(
device
=
config
.
THEANO_GPU
):
if
use
.
device_number
is
None
:
if
use
.
device_number
is
None
:
...
...
theano/sandbox/cuda/nvcc_compiler.py
浏览文件 @
f128a6d5
...
@@ -19,6 +19,15 @@ def debug(*args):
...
@@ -19,6 +19,15 @@ def debug(*args):
#sys.stderr.write('DEBUG:'+ ' '.join(str(a) for a in args)+'\n')
#sys.stderr.write('DEBUG:'+ ' '.join(str(a) for a in args)+'\n')
_logger
.
debug
(
"DEBUG: "
+
' '
.
join
(
str
(
a
)
for
a
in
args
))
_logger
.
debug
(
"DEBUG: "
+
' '
.
join
(
str
(
a
)
for
a
in
args
))
def
is_nvcc_available
():
"""Return True iff the nvcc compiler is found."""
try
:
subprocess
.
call
([
'nvcc'
,
'--version'
],
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
PIPE
)
return
True
except
:
return
False
def
nvcc_module_compile_str
(
module_name
,
src_code
,
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
def
nvcc_module_compile_str
(
module_name
,
src_code
,
location
=
None
,
include_dirs
=
[],
lib_dirs
=
[],
libs
=
[],
preargs
=
[]):
preargs
=
[]):
"""
"""
...
...
theano/tensor/opt.py
浏览文件 @
f128a6d5
...
@@ -346,7 +346,7 @@ def local_IncSubtensor_serialize(node):
...
@@ -346,7 +346,7 @@ def local_IncSubtensor_serialize(node):
#
#
# add(x, incsubtensor(b, c), incsubtensor(b, d))
# add(x, incsubtensor(b, c), incsubtensor(b, d))
# -> incsubtensor(incsubtensor(add(x,b), c), d)
# -> incsubtensor(incsubtensor(add(x,b
,b
), c), d)
"""
"""
def
movable
(
i
):
def
movable
(
i
):
...
@@ -354,7 +354,8 @@ def local_IncSubtensor_serialize(node):
...
@@ -354,7 +354,8 @@ def local_IncSubtensor_serialize(node):
return
i
.
owner
\
return
i
.
owner
\
and
isinstance
(
i
.
owner
.
op
,
T
.
IncSubtensor
)
\
and
isinstance
(
i
.
owner
.
op
,
T
.
IncSubtensor
)
\
and
i
.
type
==
o_type
\
and
i
.
type
==
o_type
\
and
len
(
i
.
clients
)
==
1
and
len
(
i
.
clients
)
==
1
\
and
not
i
.
owner
.
op
.
set_instead_of_inc
if
node
.
op
==
T
.
add
:
if
node
.
op
==
T
.
add
:
o_type
=
node
.
outputs
[
0
]
.
type
o_type
=
node
.
outputs
[
0
]
.
type
...
@@ -383,7 +384,8 @@ def local_IncSubtensor_serialize(node):
...
@@ -383,7 +384,8 @@ def local_IncSubtensor_serialize(node):
@gof.local_optimizer
([
None
])
@gof.local_optimizer
([
None
])
def
local_inplace_setsubtensor
(
node
):
def
local_inplace_setsubtensor
(
node
):
if
isinstance
(
node
.
op
,
T
.
IncSubtensor
)
and
not
node
.
op
.
inplace
:
if
isinstance
(
node
.
op
,
T
.
IncSubtensor
)
and
not
node
.
op
.
inplace
:
new_op
=
T
.
IncSubtensor
(
node
.
op
.
idx_list
,
inplace
=
True
)
new_op
=
T
.
IncSubtensor
(
node
.
op
.
idx_list
,
inplace
=
True
,
\
set_instead_of_inc
=
node
.
op
.
set_instead_of_inc
)
new_node
=
new_op
(
*
node
.
inputs
)
new_node
=
new_op
(
*
node
.
inputs
)
return
[
new_node
]
return
[
new_node
]
return
False
return
False
...
...
theano/tensor/raw_random.py
浏览文件 @
f128a6d5
...
@@ -309,7 +309,9 @@ def permutation_helper(random_state, n, shape):
...
@@ -309,7 +309,9 @@ def permutation_helper(random_state, n, shape):
"""
"""
# n should be a 0-dimension array
# n should be a 0-dimension array
assert
n
.
shape
==
()
assert
n
.
shape
==
()
n
=
n
.
item
()
# Note that it is important to convert `n` into an integer, because if it
# is a long, the numpy permutation function will crash on Windows.
n
=
int
(
n
.
item
())
out_shape
=
list
(
shape
)
out_shape
=
list
(
shape
)
out_shape
.
append
(
n
)
out_shape
.
append
(
n
)
...
...
theano/tensor/sharedvar.py
浏览文件 @
f128a6d5
...
@@ -35,7 +35,7 @@ class ScalarSharedVariable(SharedVariable, _tensor_py_operators):
...
@@ -35,7 +35,7 @@ class ScalarSharedVariable(SharedVariable, _tensor_py_operators):
@shared_constructor
@shared_constructor
def
scalar_constructor
(
value
,
name
=
None
,
strict
=
False
,
dtype
=
None
):
def
scalar_constructor
(
value
,
name
=
None
,
strict
=
False
,
dtype
=
None
):
"""SharedVariable constructor for scalar values. Default
s to
int64 or float64.
"""SharedVariable constructor for scalar values. Default
:
int64 or float64.
:note: We implement this using 0-d tensors for now.
:note: We implement this using 0-d tensors for now.
...
@@ -50,12 +50,14 @@ def scalar_constructor(value, name=None, strict=False, dtype=None):
...
@@ -50,12 +50,14 @@ def scalar_constructor(value, name=None, strict=False, dtype=None):
else
:
else
:
dtype
=
type
(
value
)
.
__name__
dtype
=
type
(
value
)
.
__name__
type
=
TensorType
(
dtype
=
dtype
,
broadcastable
=
[])
t
ensor_t
ype
=
TensorType
(
dtype
=
dtype
,
broadcastable
=
[])
try
:
try
:
# don't pass the dtype to asarray because we want this to fail if strict is True and the
# Do not pass the dtype to asarray because we want this to fail if
# types do not match
# strict is True and the types do not match.
rval
=
ScalarSharedVariable
(
type
=
type
,
value
=
numpy
.
asarray
(
value
),
name
=
name
,
strict
=
strict
)
rval
=
ScalarSharedVariable
(
type
=
tensor_type
,
value
=
numpy
.
asarray
(
value
),
name
=
name
,
strict
=
strict
)
return
rval
return
rval
except
:
except
:
traceback
.
print_exc
()
traceback
.
print_exc
()
...
...
theano/tensor/tests/test_randomstreams.py
浏览文件 @
f128a6d5
...
@@ -277,12 +277,12 @@ class T_RandomStreams(unittest.TestCase):
...
@@ -277,12 +277,12 @@ class T_RandomStreams(unittest.TestCase):
assert
numpy
.
all
(
fn_val1
==
numpy_val1
)
assert
numpy
.
all
(
fn_val1
==
numpy_val1
)
def
test_shuffle_row_elements
(
self
):
def
test_shuffle_row_elements
(
self
):
"""
Test that RandomStreams.shuffle_row_elements generates the
right results"""
"""
Ensure RandomStreams.shuffle_row_elements generates
right results"""
# Check over two calls to see if the random state is correctly updated.
# Check over two calls to see if the random state is correctly updated.
# On matrices, for each row, the elements of that row should be
#
On matrices, for each row, the elements of that row should be
shuffled.
# shuffled.
# Note that this differs from numpy.random.shuffle, where all the
elements
# Note that this differs from numpy.random.shuffle, where all the
# of the matrix are shuffled.
#
elements
of the matrix are shuffled.
mm
=
Module
()
mm
=
Module
()
mm
.
random
=
RandomStreams
(
234
)
mm
.
random
=
RandomStreams
(
234
)
m_input
=
tensor
.
dmatrix
()
m_input
=
tensor
.
dmatrix
()
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论