Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
54fad171
提交
54fad171
authored
11月 19, 2010
作者:
Razvan Pascanu
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fixed several issues I encountered (missing or confusing imports, missing
borrow argument for In, gradient of a mtrix ..)
上级
f601a0ff
隐藏空白字符变更
内嵌
并排
正在显示
6 个修改的文件
包含
19 行增加
和
14 行删除
+19
-14
ctype.txt
doc/extending/ctype.txt
+8
-5
optimization.txt
doc/extending/optimization.txt
+2
-0
type.txt
doc/extending/type.txt
+2
-2
examples.txt
doc/tutorial/examples.txt
+3
-3
using_gpu.txt
doc/tutorial/using_gpu.txt
+3
-3
io.py
theano/compile/io.py
+1
-1
没有找到文件。
doc/extending/ctype.txt
浏览文件 @
54fad171
...
...
@@ -162,7 +162,7 @@ it, it's best to publish it somewhere.
.. code-block:: python
def c_init(
self,
name, sub):
def c_init(name, sub):
return """
%(name)s = 0.0;
""" % dict(name = name)
...
...
@@ -191,7 +191,7 @@ called, without knowing for sure which of the two.
.. code-block:: python
def c_extract(
self,
name, sub):
def c_extract(name, sub):
return """
if (!PyFloat_Check(py_%(name)s)) {
PyErr_SetString(PyExc_TypeError, "expected a float");
...
...
@@ -229,7 +229,7 @@ API) and we put it in our double variable that we declared previously.
.. code-block:: python
def c_sync(
self,
name, sub):
def c_sync(name, sub):
return """
Py_XDECREF(py_%(name)s);
py_%(name)s = PyFloat_FromDouble(%(name)s);
...
...
@@ -291,7 +291,7 @@ than sorry.
.. code-block:: python
def c_cleanup(
self,
name, sub):
def c_cleanup(name, sub):
return ""
double.c_cleanup = c_cleanup
...
...
@@ -339,6 +339,9 @@ and call it:
.. theano/tests/test_tutorial.py:T_extending.test_extending_2
.. code-block:: python
from theano import function
from theano.tensor import double
x, y, z = double('x'), double('y'), double('z')
a = add(x, y)
...
...
@@ -430,7 +433,7 @@ Final version
class Double(gof.Type):
def filter(self, x, strict=False):
def filter(self, x, strict=False
, allow_downcast = False
):
if strict and not isinstance(x, float):
raise TypeError('Expected a float!')
return float(x)
...
...
doc/extending/optimization.txt
浏览文件 @
54fad171
...
...
@@ -469,6 +469,8 @@ Here are a few examples of how to use a Query on optdb to produce an
Optimizer:
.. code-block:: python
from theano.compile import optdb
# This is how the optimizer for the fast_run mode is defined
fast_run = optdb.query(Query(include = ['fast_run']))
...
...
doc/extending/type.txt
浏览文件 @
54fad171
...
...
@@ -113,7 +113,7 @@ must define ``filter`` and shall override ``values_eq_approx``.
# Note that we shadow Python's function ``filter`` with this
# definition.
def filter(x, strict=False):
def filter(x, strict=False
, allow_downcast = False
):
if strict:
if isinstance(x, float):
return x
...
...
@@ -278,7 +278,7 @@ Final version
class Double(gof.Type):
def filter(self, x, strict=False):
def filter(self, x, strict=False
, allow_downcast = False
):
if strict and not isinstance(x, float):
raise TypeError('Expected a float!')
return float(x)
...
...
doc/tutorial/examples.txt
浏览文件 @
54fad171
...
...
@@ -149,7 +149,7 @@ logistic is: :math:`ds(x)/dx = s(x) \cdot (1 - s(x))`.
.. theano/tests/test_tutorial.py:T_examples.test_examples_5
>>> x = T.dmatrix('x')
>>> s =
1 / (1 + T.exp(-x
))
>>> s =
T.sum(1 / (1 + T.exp(-x)
))
>>> gs = T.grad(s, x)
>>> dlogistic = function([x], gs)
>>> dlogistic([[0, 1], [-1, -2]])
...
...
@@ -321,7 +321,7 @@ for the purpose of one particular function.
.. theano/tests/test_tutorial.py:T_examples.test_examples_8
>>> fn_of_state = state * 2 + inc
>>> foo = lscalar() # the type (lscalar) must match the shared variable we
>>> foo =
T.
lscalar() # the type (lscalar) must match the shared variable we
>>> # are replacing with the ``givens`` list
>>> skip_shared = function([inc, foo], fn_of_state,
givens=[(state, foo)])
...
...
@@ -394,7 +394,7 @@ not affected by calling the returned function. So for example, calling
``g`` multiple times will return the same numbers.
>>> g_val0 = g() # different numbers from f_val0 and f_val1
>>> g_val
0
= g() # same numbers as g_val0 !!!
>>> g_val
1
= g() # same numbers as g_val0 !!!
An important remark is that a random variable is drawn at most once during any
single function execution. So the ``nearly_zeros`` function is guaranteed to
...
...
doc/tutorial/using_gpu.txt
浏览文件 @
54fad171
...
...
@@ -88,7 +88,7 @@ file and run it.
r = f()
print 'Looping %d times took'%iters, time.time() - t0, 'seconds'
print 'Result is', r
print 'Used the','cpu' if any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
print 'Used the','cpu' if
numpy.
any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
The program just computes the exp() of a bunch of random numbers.
Note that we use the `shared` function to
...
...
@@ -145,7 +145,7 @@ after the T.exp(x) is replaced by a GPU version of exp().
print 'Looping %d times took'%iters, time.time() - t0, 'seconds'
print 'Result is', r
print 'Numpy result is', numpy.asarray(r)
print 'Used the','cpu' if any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
print 'Used the','cpu' if
numpy.
any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
The output from this program is
...
...
@@ -200,7 +200,7 @@ that it has the un-wanted side-effect of really slowing things down.
print 'Looping %d times took'%iters, time.time() - t0, 'seconds'
print 'Result is', r
print 'Numpy result is', numpy.asarray(r)
print 'Used the','cpu' if any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
print 'Used the','cpu' if
numpy.
any( [isinstance(x.op,T.Elemwise) for x in f.maker.env.toposort()]) else 'gpu'
Running this version of the code takes just under 0.05 seconds, over 140x faster than
the CPU implementation!
...
...
theano/compile/io.py
浏览文件 @
54fad171
...
...
@@ -184,7 +184,7 @@ class In(SymbolicInput):
# try to keep it synchronized.
def
__init__
(
self
,
variable
,
name
=
None
,
value
=
None
,
update
=
None
,
mutable
=
None
,
strict
=
False
,
allow_downcast
=
False
,
autoname
=
True
,
implicit
=
None
):
implicit
=
None
,
borrow
=
False
):
if
implicit
is
None
:
implicit
=
(
isinstance
(
value
,
gof
.
Container
)
or
isinstance
(
value
,
SharedVariable
))
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论