Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
5a90f43a
提交
5a90f43a
authored
11月 09, 2012
作者:
nouiz
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #1060 from delallea/minor
Minor stuff
上级
e17f9005
bb8c54ae
隐藏空白字符变更
内嵌
并排
正在显示
11 个修改的文件
包含
28 行增加
和
23 行删除
+28
-23
theano.txt
doc/cifarSC2011/theano.txt
+1
-1
logreg_example.py
doc/hpcs2011_tutorial/logreg_example.py
+1
-1
extending_theano.txt
doc/tutorial/extending_theano.txt
+2
-2
modes.txt
doc/tutorial/modes.txt
+2
-2
modes_solution_1.py
doc/tutorial/modes_solution_1.py
+1
-1
printing_drawing.txt
doc/tutorial/printing_drawing.txt
+1
-1
using_gpu.txt
doc/tutorial/using_gpu.txt
+3
-4
using_gpu_solution_1.py
doc/tutorial/using_gpu_solution_1.py
+1
-1
scan.py
theano/sandbox/scan_module/scan.py
+1
-1
scan.py
theano/scan_module/scan.py
+1
-1
basic.py
theano/tensor/basic.py
+14
-8
没有找到文件。
doc/cifarSC2011/theano.txt
浏览文件 @
5a90f43a
...
@@ -208,7 +208,7 @@ Exercise 2
...
@@ -208,7 +208,7 @@ Exercise 2
# Construct Theano expression graph
# Construct Theano expression graph
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabily of having a one
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabil
it
y of having a one
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
...
...
doc/hpcs2011_tutorial/logreg_example.py
浏览文件 @
5a90f43a
...
@@ -20,7 +20,7 @@ y.tag.test_value = D[1]
...
@@ -20,7 +20,7 @@ y.tag.test_value = D[1]
# Construct Theano expression graph
# Construct Theano expression graph
p_1
=
1
/
(
1
+
T
.
exp
(
-
T
.
dot
(
x
,
w
)
-
b
))
# Probabily of having a one
p_1
=
1
/
(
1
+
T
.
exp
(
-
T
.
dot
(
x
,
w
)
-
b
))
# Probabil
it
y of having a one
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
xent
=
-
y
*
T
.
log
(
p_1
)
-
(
1
-
y
)
*
T
.
log
(
1
-
p_1
)
# Cross-entropy
xent
=
-
y
*
T
.
log
(
p_1
)
-
(
1
-
y
)
*
T
.
log
(
1
-
p_1
)
# Cross-entropy
cost
=
xent
.
mean
()
+
0.01
*
(
w
**
2
)
.
sum
()
# The cost to optimize
cost
=
xent
.
mean
()
+
0.01
*
(
w
**
2
)
.
sum
()
# The cost to optimize
...
...
doc/tutorial/extending_theano.txt
浏览文件 @
5a90f43a
...
@@ -9,7 +9,7 @@ Theano Graphs
...
@@ -9,7 +9,7 @@ Theano Graphs
=============
=============
- Theano works with symbolic graphs.
- Theano works with symbolic graphs.
- Those graphs are bi-partite graphs (graph with 2 types of nodes).
- Those graphs are bi-partite graphs (graph
s
with 2 types of nodes).
- The two types of nodes are ``Apply`` and ``Variable`` nodes.
- The two types of nodes are ``Apply`` and ``Variable`` nodes.
- Each ``Apply`` node has a link to the op that it executes.
- Each ``Apply`` node has a link to the op that it executes.
...
@@ -359,7 +359,7 @@ file containing a specific test of interest and run the file. In this example, t
...
@@ -359,7 +359,7 @@ file containing a specific test of interest and run the file. In this example, t
t.setUp()
t.setUp()
t.test_double_rop()
t.test_double_rop()
We recomm
a
nd that when we execute a file, we run all tests in that
We recomm
e
nd that when we execute a file, we run all tests in that
file. This can be done by adding this at the end of your test files:
file. This can be done by adding this at the end of your test files:
.. code-block:: python
.. code-block:: python
...
...
doc/tutorial/modes.txt
浏览文件 @
5a90f43a
...
@@ -67,7 +67,7 @@ Consider the logistic regression:
...
@@ -67,7 +67,7 @@ Consider the logistic regression:
#print w.get_value(), b.get_value()
#print w.get_value(), b.get_value()
# Construct Theano expression graph
# Construct Theano expression graph
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabily of having a one
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabil
it
y of having a one
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
...
@@ -110,7 +110,7 @@ as it will be useful later on.
...
@@ -110,7 +110,7 @@ as it will be useful later on.
.. Note::
.. Note::
* Apply the Theano flag ``floatX=float32``
through (
``theano.config.floatX``) in your code.
* Apply the Theano flag ``floatX=float32``
(through
``theano.config.floatX``) in your code.
* Cast inputs before storing them into a shared variable.
* Cast inputs before storing them into a shared variable.
* Circumvent the automatic cast of *int32* with *float32* to *float64*:
* Circumvent the automatic cast of *int32* with *float32* to *float64*:
...
...
doc/tutorial/modes_solution_1.py
浏览文件 @
5a90f43a
...
@@ -27,7 +27,7 @@ y.tag.test_value = D[1]
...
@@ -27,7 +27,7 @@ y.tag.test_value = D[1]
#print w.get_value(), b.get_value()
#print w.get_value(), b.get_value()
# Construct Theano expression graph
# Construct Theano expression graph
p_1
=
1
/
(
1
+
tt
.
exp
(
-
tt
.
dot
(
x
,
w
)
-
b
))
# Probabily of having a one
p_1
=
1
/
(
1
+
tt
.
exp
(
-
tt
.
dot
(
x
,
w
)
-
b
))
# Probabil
it
y of having a one
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
xent
=
-
y
*
tt
.
log
(
p_1
)
-
(
1
-
y
)
*
tt
.
log
(
1
-
p_1
)
# Cross-entropy
xent
=
-
y
*
tt
.
log
(
p_1
)
-
(
1
-
y
)
*
tt
.
log
(
1
-
p_1
)
# Cross-entropy
cost
=
tt
.
cast
(
xent
.
mean
(),
'float32'
)
+
\
cost
=
tt
.
cast
(
xent
.
mean
(),
'float32'
)
+
\
...
...
doc/tutorial/printing_drawing.txt
浏览文件 @
5a90f43a
...
@@ -42,7 +42,7 @@ The following output depicts the pre- and post- compilation graphs.
...
@@ -42,7 +42,7 @@ The following output depicts the pre- and post- compilation graphs.
# Construct Theano expression graph
# Construct Theano expression graph
p_1 = 1 / (1 + T.exp(-T.dot(x, w) - b)) # Probabily of having a one
p_1 = 1 / (1 + T.exp(-T.dot(x, w) - b)) # Probabil
it
y of having a one
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
xent = -y * T.log(p_1) - (1 - y) * T.log(1 - p_1) # Cross-entropy
xent = -y * T.log(p_1) - (1 - y) * T.log(1 - p_1) # Cross-entropy
cost = xent.mean() + 0.01 * (w ** 2).sum() # The cost to optimize
cost = xent.mean() + 0.01 * (w ** 2).sum() # The cost to optimize
...
...
doc/tutorial/using_gpu.txt
浏览文件 @
5a90f43a
...
@@ -342,7 +342,7 @@ Consider again the logistic regression:
...
@@ -342,7 +342,7 @@ Consider again the logistic regression:
#print w.get_value(), b.get_value()
#print w.get_value(), b.get_value()
# Construct Theano expression graph
# Construct Theano expression graph
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabily of having a one
p_1 = 1 / (1 + T.exp(-T.dot(x, w)-b)) # Probabil
it
y of having a one
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
prediction = p_1 > 0.5 # The prediction that is done: 0 or 1
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
xent = -y*T.log(p_1) - (1-y)*T.log(1-p_1) # Cross-entropy
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
cost = xent.mean() + 0.01*(w**2).sum() # The cost to optimize
...
@@ -400,7 +400,7 @@ What can be done to further increase the speed of the GPU version? Put your idea
...
@@ -400,7 +400,7 @@ What can be done to further increase the speed of the GPU version? Put your idea
* Use the Theano flag ``device=gpu`` to require use of the GPU device.
* Use the Theano flag ``device=gpu`` to require use of the GPU device.
* Use ``device=gpu{0, 1, ...}`` to specify which GPU if you have more than one.
* Use ``device=gpu{0, 1, ...}`` to specify which GPU if you have more than one.
* Apply the Theano flag ``floatX=float32``
through (
``theano.config.floatX``) in your code.
* Apply the Theano flag ``floatX=float32``
(through
``theano.config.floatX``) in your code.
* ``Cast`` inputs before storing them into a ``shared`` variable.
* ``Cast`` inputs before storing them into a ``shared`` variable.
* Circumvent the automatic cast of *int32* with *float32* to *float64*:
* Circumvent the automatic cast of *int32* with *float32* to *float64*:
...
@@ -623,5 +623,4 @@ only applicable to computations involving a single output. Hence, to gain
...
@@ -623,5 +623,4 @@ only applicable to computations involving a single output. Hence, to gain
efficiency over the basic solution that is asked here, the two operations would
efficiency over the basic solution that is asked here, the two operations would
have to be jointly optimized explicitly in the code.)
have to be jointly optimized explicitly in the code.)
Modify and execute to support *stride* (i.e. so as not constrain the input to be *C-contiguous*).
Modify and execute to support *stride* (i.e. to avoid constraining the input to be *C-contiguous*).
doc/tutorial/using_gpu_solution_1.py
浏览文件 @
5a90f43a
...
@@ -38,7 +38,7 @@ y.tag.test_value = D[1]
...
@@ -38,7 +38,7 @@ y.tag.test_value = D[1]
#print w.get_value(), b.get_value()
#print w.get_value(), b.get_value()
# Construct Theano expression graph
# Construct Theano expression graph
p_1
=
1
/
(
1
+
tt
.
exp
(
-
tt
.
dot
(
x
,
w
)
-
b
))
# Probabily of having a one
p_1
=
1
/
(
1
+
tt
.
exp
(
-
tt
.
dot
(
x
,
w
)
-
b
))
# Probabil
it
y of having a one
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
prediction
=
p_1
>
0.5
# The prediction that is done: 0 or 1
xent
=
-
y
*
tt
.
log
(
p_1
)
-
(
1
-
y
)
*
tt
.
log
(
1
-
p_1
)
# Cross-entropy
xent
=
-
y
*
tt
.
log
(
p_1
)
-
(
1
-
y
)
*
tt
.
log
(
1
-
p_1
)
# Cross-entropy
cost
=
tt
.
cast
(
xent
.
mean
(),
'float32'
)
+
\
cost
=
tt
.
cast
(
xent
.
mean
(),
'float32'
)
+
\
...
...
theano/sandbox/scan_module/scan.py
浏览文件 @
5a90f43a
...
@@ -132,7 +132,7 @@ def scan(fn,
...
@@ -132,7 +132,7 @@ def scan(fn,
The list of ``non_sequences`` can also contain shared variables
The list of ``non_sequences`` can also contain shared variables
used in the function, though ``scan`` is able to figure those
used in the function, though ``scan`` is able to figure those
out on its own so they can be skipped. For the clarity of the
out on its own so they can be skipped. For the clarity of the
code we recomm
a
nd though to provide them to scan. To some extend
code we recomm
e
nd though to provide them to scan. To some extend
``scan`` can also figure out other ``non sequences`` (not shared)
``scan`` can also figure out other ``non sequences`` (not shared)
even if not passed to scan (but used by `fn`). A simple example of
even if not passed to scan (but used by `fn`). A simple example of
this would be :
this would be :
...
...
theano/scan_module/scan.py
浏览文件 @
5a90f43a
...
@@ -130,7 +130,7 @@ def scan(fn,
...
@@ -130,7 +130,7 @@ def scan(fn,
The list of ``non_sequences`` can also contain shared variables
The list of ``non_sequences`` can also contain shared variables
used in the function, though ``scan`` is able to figure those
used in the function, though ``scan`` is able to figure those
out on its own so they can be skipped. For the clarity of the
out on its own so they can be skipped. For the clarity of the
code we recomm
a
nd though to provide them to scan. To some extend
code we recomm
e
nd though to provide them to scan. To some extend
``scan`` can also figure out other ``non sequences`` (not shared)
``scan`` can also figure out other ``non sequences`` (not shared)
even if not passed to scan (but used by `fn`). A simple example of
even if not passed to scan (but used by `fn`). A simple example of
this would be :
this would be :
...
...
theano/tensor/basic.py
浏览文件 @
5a90f43a
...
@@ -2685,6 +2685,7 @@ where = switch
...
@@ -2685,6 +2685,7 @@ where = switch
# Bit-wise
# Bit-wise
##########################
##########################
@_scal_elemwise_with_nfunc
(
'bitwise_and'
,
2
,
1
)
@_scal_elemwise_with_nfunc
(
'bitwise_and'
,
2
,
1
)
def
and_
(
a
,
b
):
def
and_
(
a
,
b
):
"""bitwise a & b"""
"""bitwise a & b"""
...
@@ -4334,8 +4335,10 @@ class Subtensor(Op):
...
@@ -4334,8 +4335,10 @@ class Subtensor(Op):
while (inner_ii <
%(c_prefix)
s_NDIM(
%(xview)
s))
while (inner_ii <
%(c_prefix)
s_NDIM(
%(xview)
s))
{
{
assert (outer_ii <
%(c_prefix)
s_NDIM(
%(x)
s));
assert (outer_ii <
%(c_prefix)
s_NDIM(
%(x)
s));
%(set_dim)
s(
%(xview)
s, inner_ii,
%(c_prefix)
s_DIMS(
%(x)
s)[outer_ii]);
%(set_dim)
s(
%(xview)
s, inner_ii,
%(set_stride)
s(
%(xview)
s, inner_ii,
%(c_prefix)
s_STRIDES(
%(x)
s)[outer_ii]);
%(c_prefix)
s_DIMS(
%(x)
s)[outer_ii]);
%(set_stride)
s(
%(xview)
s, inner_ii,
%(c_prefix)
s_STRIDES(
%(x)
s)[outer_ii]);
inner_ii += 1;
inner_ii += 1;
outer_ii += 1;
outer_ii += 1;
}
}
...
@@ -4464,19 +4467,20 @@ def set_subtensor(x, y, inplace=False,
...
@@ -4464,19 +4467,20 @@ def set_subtensor(x, y, inplace=False,
return
inc_subtensor
(
x
,
y
,
inplace
,
set_instead_of_inc
=
True
,
return
inc_subtensor
(
x
,
y
,
inplace
,
set_instead_of_inc
=
True
,
tolerate_inplace_aliasing
=
tolerate_inplace_aliasing
)
tolerate_inplace_aliasing
=
tolerate_inplace_aliasing
)
def
batched_dot
(
x
,
y
):
def
batched_dot
(
x
,
y
):
"""
"""
:param x: A Tensor with sizes e.g.: for 3D (dim1, dim3, dim2)
:param x: A Tensor with sizes e.g.: for 3D (dim1, dim3, dim2)
:param y: A Tensor with sizes e.g.: for 3D (dim1, dim2, dim4)
:param y: A Tensor with sizes e.g.: for 3D (dim1, dim2, dim4)
This function computes the dot product between the two tensors, by
iterating
This function computes the dot product between the two tensors, by
over the first dimension using scan.
iterating
over the first dimension using scan.
Returns a tensor of size e.g. if it is 3D: (dim1, dim3, dim4)
Returns a tensor of size e.g. if it is 3D: (dim1, dim3, dim4)
Example:
Example:
>>> first = T.tensor3('first')
>>> first = T.tensor3('first')
>>> second = T.tensor3('second')
>>> second = T.tensor3('second')
>>> result = batched_dot(first, second)
>>> result = batched_dot(first, second)
:note: This is a subset of numpy.einsum, but we do not provide it for now.
:note: This is a subset of numpy.einsum, but we do not provide it for now.
But numpy einsum is slower th
e
n dot or tensordot:
But numpy einsum is slower th
a
n dot or tensordot:
http://mail.scipy.org/pipermail/numpy-discussion/2012-October/064259.html
http://mail.scipy.org/pipermail/numpy-discussion/2012-October/064259.html
"""
"""
result
,
updates
=
theano
.
scan
(
fn
=
lambda
x_mat
,
y_mat
:
result
,
updates
=
theano
.
scan
(
fn
=
lambda
x_mat
,
y_mat
:
...
@@ -4486,6 +4490,7 @@ def batched_dot(x, y):
...
@@ -4486,6 +4490,7 @@ def batched_dot(x, y):
non_sequences
=
None
)
non_sequences
=
None
)
return
result
return
result
def
inc_subtensor
(
x
,
y
,
inplace
=
False
,
set_instead_of_inc
=
False
,
def
inc_subtensor
(
x
,
y
,
inplace
=
False
,
set_instead_of_inc
=
False
,
tolerate_inplace_aliasing
=
False
):
tolerate_inplace_aliasing
=
False
):
"""Return x with the given subtensor incremented by y.
"""Return x with the given subtensor incremented by y.
...
@@ -5725,7 +5730,8 @@ class Reshape(Op):
...
@@ -5725,7 +5730,8 @@ class Reshape(Op):
// -- will err if this will downcast. This could happen if the
// -- will err if this will downcast. This could happen if the
// -- user pass an int64 dtype, but npy_intp endup being int32.
// -- user pass an int64 dtype, but npy_intp endup being int32.
new_dims[ii] = ((dtype_
%(shp)
s*)(
new_dims[ii] = ((dtype_
%(shp)
s*)(
PyArray_BYTES(
%(shp)
s) + ii * PyArray_STRIDES(
%(shp)
s)[0]))[0];
PyArray_BYTES(
%(shp)
s) +
ii * PyArray_STRIDES(
%(shp)
s)[0]))[0];
}
}
Py_XDECREF(
%(z)
s);
Py_XDECREF(
%(z)
s);
%(z)
s = (PyArrayObject *) PyArray_Newshape(
%(x)
s, &newshape,
%(z)
s = (PyArrayObject *) PyArray_Newshape(
%(x)
s, &newshape,
...
@@ -5937,8 +5943,8 @@ def tile(x, reps, ndim=None):
...
@@ -5937,8 +5943,8 @@ def tile(x, reps, ndim=None):
ndim
=
len
(
reps
)
ndim
=
len
(
reps
)
# backport
# backport
# ndim = len(reps) if ndim is None else ndim
# not sure if len(shp) is going
# ndim = len(reps) if ndim is None else ndim
# to work.
#
not sure if len(shp) is going
to work.
if
ndim
not
in
tile
.
op
:
if
ndim
not
in
tile
.
op
:
tile
.
op
[
ndim
]
=
Tile
(
ndim
)
tile
.
op
[
ndim
]
=
Tile
(
ndim
)
return
tile
.
op
[
ndim
](
x
,
reps
)
return
tile
.
op
[
ndim
](
x
,
reps
)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论