Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
6b02f8ca
提交
6b02f8ca
authored
2月 17, 2016
作者:
Frédéric Bastien
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #4030 from hantek/fixtesterr
solving doc test failures
上级
3adaa82f
2c1f7d80
显示空白字符变更
内嵌
并排
正在显示
13 个修改的文件
包含
46 行增加
和
52 行删除
+46
-52
.travis.yml
.travis.yml
+1
-1
advanced_theano.txt
doc/cifarSC2011/advanced_theano.txt
+5
-5
extending_theano.txt
doc/extending/extending_theano.txt
+10
-10
using_params.txt
doc/extending/using_params.txt
+0
-5
install_windows.txt
doc/install_windows.txt
+3
-3
scan.txt
doc/library/scan.txt
+1
-1
debug_faq.txt
doc/tutorial/debug_faq.txt
+1
-1
examples.txt
doc/tutorial/examples.txt
+7
-7
loading_and_saving.txt
doc/tutorial/loading_and_saving.txt
+6
-9
printing_drawing.txt
doc/tutorial/printing_drawing.txt
+3
-3
profiling.txt
doc/tutorial/profiling.txt
+5
-4
function.py
theano/compile/function.py
+2
-1
pkl_utils.py
theano/misc/pkl_utils.py
+2
-2
没有找到文件。
.travis.yml
浏览文件 @
6b02f8ca
...
@@ -66,7 +66,7 @@ script:
...
@@ -66,7 +66,7 @@ script:
-
cd -; cd Theano
-
cd -; cd Theano
-
theano-nose -v $PART
-
theano-nose -v $PART
-
if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --nopdf --check; fi
-
if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --nopdf --check; fi
#
- if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --test --check; fi
-
if [[ $DOC == "1" ]]; then python doc/scripts/docgen.py --test --check; fi
after_failure
:
after_failure
:
-
cat /home/travis/.pip/pip.log
-
cat /home/travis/.pip/pip.log
doc/cifarSC2011/advanced_theano.txt
浏览文件 @
6b02f8ca
...
@@ -41,14 +41,14 @@ Conditions
...
@@ -41,14 +41,14 @@ Conditions
n_times = 10
n_times = 10
tic = time.clock()
tic = time.clock()
for i in
x
range(n_times):
for i in range(n_times):
f_switch(val1, val2, big_mat1, big_mat2)
f_switch(val1, val2, big_mat1, big_mat2)
print
'time spent evaluating both values %f sec'%(time.clock()-tic
)
print
('time spent evaluating both values %f sec' % (time.clock()-tic)
)
tic = time.clock()
tic = time.clock()
for i in
x
range(n_times):
for i in range(n_times):
f_lazyifelse(val1, val2, big_mat1, big_mat2)
f_lazyifelse(val1, val2, big_mat1, big_mat2)
print
'time spent evaluating one value %f sec'%(time.clock()-tic
)
print
('time spent evaluating one value %f sec' % (time.clock()-tic)
)
.. testoutput::
.. testoutput::
:hide:
:hide:
...
@@ -142,7 +142,7 @@ Loops
...
@@ -142,7 +142,7 @@ Loops
outputs=polynomial)
outputs=polynomial)
test_coeff = numpy.asarray([1, 0, 2], dtype=numpy.float32)
test_coeff = numpy.asarray([1, 0, 2], dtype=numpy.float32)
print
calculate_polynomial(test_coeff, 3
)
print
(calculate_polynomial(test_coeff, 3)
)
.. testoutput::
.. testoutput::
...
...
doc/extending/extending_theano.txt
浏览文件 @
6b02f8ca
...
@@ -412,8 +412,9 @@ but it must not influence the semantics of the Op output.
...
@@ -412,8 +412,9 @@ but it must not influence the semantics of the Op output.
You can try the new Op as follows:
You can try the new Op as follows:
.. testcode:: example
(Using make_node)
.. testcode:: example
import theano
x = theano.tensor.matrix()
x = theano.tensor.matrix()
f = theano.function([x], DoubleOp1()(x))
f = theano.function([x], DoubleOp1()(x))
import numpy
import numpy
...
@@ -425,10 +426,9 @@ You can try the new Op as follows:
...
@@ -425,10 +426,9 @@ You can try the new Op as follows:
.. testoutput:: example
.. testoutput:: example
:hide:
:hide:
:options: +ELLIPSIS
:options: +ELLIPSIS
, +SKIP
...
<BLANKLINE>
...
.. code-block:: none
.. code-block:: none
...
@@ -443,8 +443,9 @@ You can try the new Op as follows:
...
@@ -443,8 +443,9 @@ You can try the new Op as follows:
[ 1.5465443 1.30803715 1.53125983 1.88291403]
[ 1.5465443 1.30803715 1.53125983 1.88291403]
[ 1.6904152 0.61000201 1.76861002 1.9163731 ]]
[ 1.6904152 0.61000201 1.76861002 1.9163731 ]]
.. testcode:: example
(Using itypes and otypes)
.. testcode:: example
import theano
x = theano.tensor.matrix()
x = theano.tensor.matrix()
f = theano.function([x], DoubleOp2()(x))
f = theano.function([x], DoubleOp2()(x))
import numpy
import numpy
...
@@ -457,10 +458,9 @@ You can try the new Op as follows:
...
@@ -457,10 +458,9 @@ You can try the new Op as follows:
.. testoutput:: example
.. testoutput:: example
:hide:
:hide:
:options: +ELLIPSIS
:options: +ELLIPSIS
, +SKIP
...
<BLANKLINE>
...
.. code-block:: none
.. code-block:: none
...
@@ -503,8 +503,8 @@ and ``b`` are equal.
...
@@ -503,8 +503,8 @@ and ``b`` are equal.
def make_node(self, x):
def make_node(self, x):
# check that the theano version has support for __props__.
# check that the theano version has support for __props__.
assert hasattr(self, '_props'),
"Your version of theano is too old
assert hasattr(self, '_props'),
("Your version of theano is too"
to support __props__."
"old to support __props__.")
x = theano.tensor.as_tensor_variable(x)
x = theano.tensor.as_tensor_variable(x)
return theano.Apply(self, [x], [x.type()])
return theano.Apply(self, [x], [x.type()])
...
...
doc/extending/using_params.txt
浏览文件 @
6b02f8ca
...
@@ -156,9 +156,6 @@ the params type.
...
@@ -156,9 +156,6 @@ the params type.
return ("%(z)s = %(x)s * PyFloat_AsDouble(%(p)s);" %
return ("%(z)s = %(x)s * PyFloat_AsDouble(%(p)s);" %
dict(z=outputs[0], x=inputs[0], p=sub['params']))
dict(z=outputs[0], x=inputs[0], p=sub['params']))
.. testoutput::
:hide:
A more complex example
A more complex example
----------------------
----------------------
...
@@ -225,5 +222,3 @@ weights.
...
@@ -225,5 +222,3 @@ weights.
%(z)s = alpha_%(name)s * %(x)s + beta_%(name)s * %(y)s;
%(z)s = alpha_%(name)s * %(x)s + beta_%(name)s * %(y)s;
""" % dict(name=name, z=outputs[0], x=inputs[0], y=inputs[1])
""" % dict(name=name, z=outputs[0], x=inputs[0], y=inputs[1])
.. testoutput::
:hide:
doc/install_windows.txt
浏览文件 @
6b02f8ca
...
@@ -420,9 +420,9 @@ Create a test file containing:
...
@@ -420,9 +420,9 @@ Create a test file containing:
t_start = time.time()
t_start = time.time()
tAB = mf(A,B)
tAB = mf(A,B)
t_end = time.time()
t_end = time.time()
print
"NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" %(
print
(
"NP time: %f[s], theano time: %f[s] (times should be close when run on CPU!)" %(
np_end-np_start, t_end-t_start)
np_end-np_start, t_end-t_start)
)
print
"Result difference: %f" % (np.abs(AB-tAB).max(),
)
print
("Result difference: %f" % (np.abs(AB-tAB).max(), )
)
.. testoutput::
.. testoutput::
:hide:
:hide:
...
...
doc/library/scan.txt
浏览文件 @
6b02f8ca
...
@@ -187,7 +187,7 @@ downcast** of the latter.
...
@@ -187,7 +187,7 @@ downcast** of the latter.
# test
# test
some_num = 15
some_num = 15
print(triangular_sequence(some_num))
print(triangular_sequence(some_num))
print([n * (n + 1) // 2 for n in
x
range(some_num)])
print([n * (n + 1) // 2 for n in range(some_num)])
.. testoutput::
.. testoutput::
...
...
doc/tutorial/debug_faq.txt
浏览文件 @
6b02f8ca
...
@@ -336,7 +336,7 @@ shows how to print all inputs and outputs:
...
@@ -336,7 +336,7 @@ shows how to print all inputs and outputs:
end='')
end='')
def inspect_outputs(i, node, fn):
def inspect_outputs(i, node, fn):
print("output(s) value(s):", [output[0] for output in fn.outputs])
print("
output(s) value(s):", [output[0] for output in fn.outputs])
x = theano.tensor.dscalar('x')
x = theano.tensor.dscalar('x')
f = theano.function([x], [5 * x],
f = theano.function([x], [5 * x],
...
...
doc/tutorial/examples.txt
浏览文件 @
6b02f8ca
...
@@ -125,7 +125,7 @@ array(35.0)
...
@@ -125,7 +125,7 @@ array(35.0)
This makes use of the :ref:`In <function_inputs>` class which allows
This makes use of the :ref:`In <function_inputs>` class which allows
you to specify properties of your function's parameters with greater detail. Here we
you to specify properties of your function's parameters with greater detail. Here we
give a default value of 1 for *y* by creating a ``In`` instance with
give a default value of 1 for *y* by creating a ``In`` instance with
its ``
default
`` field set to 1.
its ``
value
`` field set to 1.
Inputs with default values must follow inputs without default
Inputs with default values must follow inputs without default
values (like Python's functions). There can be multiple inputs with default values. These parameters can
values (like Python's functions). There can be multiple inputs with default values. These parameters can
...
@@ -206,15 +206,15 @@ Let's try it out!
...
@@ -206,15 +206,15 @@ Let's try it out!
.. If you modify this code, also change :
.. If you modify this code, also change :
.. theano/tests/test_tutorial.py:T_examples.test_examples_8
.. theano/tests/test_tutorial.py:T_examples.test_examples_8
>>>
state.get_value(
)
>>>
print(state.get_value()
)
0
0
>>> accumulator(1)
>>> accumulator(1)
array(0)
array(0)
>>>
state.get_value(
)
>>>
print(state.get_value()
)
1
1
>>> accumulator(300)
>>> accumulator(300)
array(1)
array(1)
>>>
state.get_value(
)
>>>
print(state.get_value()
)
301
301
It is possible to reset the state. Just use the ``.set_value()`` method:
It is possible to reset the state. Just use the ``.set_value()`` method:
...
@@ -222,7 +222,7 @@ It is possible to reset the state. Just use the ``.set_value()`` method:
...
@@ -222,7 +222,7 @@ It is possible to reset the state. Just use the ``.set_value()`` method:
>>> state.set_value(-1)
>>> state.set_value(-1)
>>> accumulator(3)
>>> accumulator(3)
array(-1)
array(-1)
>>>
state.get_value(
)
>>>
print(state.get_value()
)
2
2
As we mentioned above, you can define more than one function to use the same
As we mentioned above, you can define more than one function to use the same
...
@@ -234,7 +234,7 @@ shared variable. These functions can all update the value.
...
@@ -234,7 +234,7 @@ shared variable. These functions can all update the value.
>>> decrementor = function([inc], state, updates=[(state, state-inc)])
>>> decrementor = function([inc], state, updates=[(state, state-inc)])
>>> decrementor(2)
>>> decrementor(2)
array(2)
array(2)
>>>
state.get_value(
)
>>>
print(state.get_value()
)
0
0
You might be wondering why the updates mechanism exists. You can always
You might be wondering why the updates mechanism exists. You can always
...
@@ -261,7 +261,7 @@ for the purpose of one particular function.
...
@@ -261,7 +261,7 @@ for the purpose of one particular function.
>>> skip_shared = function([inc, foo], fn_of_state, givens=[(state, foo)])
>>> skip_shared = function([inc, foo], fn_of_state, givens=[(state, foo)])
>>> skip_shared(1, 3) # we're using 3 for the state, not state.value
>>> skip_shared(1, 3) # we're using 3 for the state, not state.value
array(7)
array(7)
>>>
state.get_value(
) # old state still there, but we didn't use it
>>>
print(state.get_value()
) # old state still there, but we didn't use it
0
0
The ``givens`` parameter can be used to replace any symbolic variable, not just a
The ``givens`` parameter can be used to replace any symbolic variable, not just a
...
...
doc/tutorial/loading_and_saving.txt
浏览文件 @
6b02f8ca
...
@@ -30,10 +30,7 @@ The Basics of Pickling
...
@@ -30,10 +30,7 @@ The Basics of Pickling
The two modules ``pickle`` and ``cPickle`` have the same functionalities, but
The two modules ``pickle`` and ``cPickle`` have the same functionalities, but
``cPickle``, coded in C, is much faster.
``cPickle``, coded in C, is much faster.
.. If you modify this code, also change :
>>> from six.moves import cPickle
.. theano/tests/test_tutorial.py:T_loading_and_saving.test_loading_and_saving_3
>>> import cPickle
You can serialize (or *save*, or *pickle*) objects to a file with
You can serialize (or *save*, or *pickle*) objects to a file with
``cPickle.dump``:
``cPickle.dump``:
...
@@ -42,7 +39,7 @@ You can serialize (or *save*, or *pickle*) objects to a file with
...
@@ -42,7 +39,7 @@ You can serialize (or *save*, or *pickle*) objects to a file with
my_obj = object()
my_obj = object()
>>> f =
file
('obj.save', 'wb')
>>> f =
open
('obj.save', 'wb')
>>> cPickle.dump(my_obj, f, protocol=cPickle.HIGHEST_PROTOCOL)
>>> cPickle.dump(my_obj, f, protocol=cPickle.HIGHEST_PROTOCOL)
>>> f.close()
>>> f.close()
...
@@ -60,7 +57,7 @@ You can serialize (or *save*, or *pickle*) objects to a file with
...
@@ -60,7 +57,7 @@ You can serialize (or *save*, or *pickle*) objects to a file with
To de-serialize (or *load*, or *unpickle*) a pickled file, use
To de-serialize (or *load*, or *unpickle*) a pickled file, use
``cPickle.load``:
``cPickle.load``:
>>> f =
file
('obj.save', 'rb')
>>> f =
open
('obj.save', 'rb')
>>> loaded_obj = cPickle.load(f)
>>> loaded_obj = cPickle.load(f)
>>> f.close()
>>> f.close()
...
@@ -74,14 +71,14 @@ same order):
...
@@ -74,14 +71,14 @@ same order):
obj2 = object()
obj2 = object()
obj3 = object()
obj3 = object()
>>> f =
file
('objects.save', 'wb')
>>> f =
open
('objects.save', 'wb')
>>> for obj in [obj1, obj2, obj3]:
>>> for obj in [obj1, obj2, obj3]:
... cPickle.dump(obj, f, protocol=cPickle.HIGHEST_PROTOCOL)
... cPickle.dump(obj, f, protocol=cPickle.HIGHEST_PROTOCOL)
>>> f.close()
>>> f.close()
Then:
Then:
>>> f =
file
('objects.save', 'rb')
>>> f =
open
('objects.save', 'rb')
>>> loaded_objects = []
>>> loaded_objects = []
>>> for i in range(3):
>>> for i in range(3):
... loaded_objects.append(cPickle.load(f))
... loaded_objects.append(cPickle.load(f))
...
@@ -121,7 +118,7 @@ For instance, you can define functions along the lines of:
...
@@ -121,7 +118,7 @@ For instance, you can define functions along the lines of:
def __setstate__(self, d):
def __setstate__(self, d):
self.__dict__.update(d)
self.__dict__.update(d)
self.training_set = cPickle.load(
file
(self.training_set_file, 'rb'))
self.training_set = cPickle.load(
open
(self.training_set_file, 'rb'))
Robust Serialization
Robust Serialization
...
...
doc/tutorial/printing_drawing.txt
浏览文件 @
6b02f8ca
...
@@ -66,7 +66,7 @@ Debug Print
...
@@ -66,7 +66,7 @@ Debug Print
The pre-compilation graph:
The pre-compilation graph:
>>> theano.printing.debugprint(prediction) # doctest: +NORMALIZE_WHITESPACE
>>> theano.printing.debugprint(prediction) # doctest: +NORMALIZE_WHITESPACE
, +ELLIPSIS
Elemwise{gt,no_inplace} [id A] ''
Elemwise{gt,no_inplace} [id A] ''
|Elemwise{true_div,no_inplace} [id B] ''
|Elemwise{true_div,no_inplace} [id B] ''
| |DimShuffle{x} [id C] ''
| |DimShuffle{x} [id C] ''
...
@@ -87,9 +87,9 @@ Elemwise{gt,no_inplace} [id A] ''
...
@@ -87,9 +87,9 @@ Elemwise{gt,no_inplace} [id A] ''
The post-compilation graph:
The post-compilation graph:
>>> theano.printing.debugprint(predict) # doctest: +NORMALIZE_WHITESPACE
>>> theano.printing.debugprint(predict) # doctest: +NORMALIZE_WHITESPACE
, +ELLIPSIS
Elemwise{Composite{GT(scalar_sigmoid((-((-i0) - i1))), i2)}} [id A] '' 4
Elemwise{Composite{GT(scalar_sigmoid((-((-i0) - i1))), i2)}} [id A] '' 4
|
C
Gemv{inplace} [id B] '' 3
|
...
Gemv{inplace} [id B] '' 3
| |AllocEmpty{dtype='float64'} [id C] '' 2
| |AllocEmpty{dtype='float64'} [id C] '' 2
| | |Shape_i{0} [id D] '' 1
| | |Shape_i{0} [id D] '' 1
| | |x [id E]
| | |x [id E]
...
...
doc/tutorial/profiling.txt
浏览文件 @
6b02f8ca
...
@@ -32,12 +32,13 @@ functions using either of the following two options:
...
@@ -32,12 +32,13 @@ functions using either of the following two options:
functions but one or more specific function(s).
functions but one or more specific function(s).
- You can also combine the profile of many functions:
- You can also combine the profile of many functions:
.. testcode::
.. doctest::
:hide:
profile = theano.compile.ProfileStats()
profile = theano.compile.ProfileStats()
f = theano.function(..., profile=profile)
f = theano.function(..., profile=profile)
# doctest: +SKIP
g = theano.function(..., profile=profile)
g = theano.function(..., profile=profile)
# doctest: +SKIP
...
...
# doctest: +SKIP
profile.print_summary()
profile.print_summary()
...
...
theano/compile/function.py
浏览文件 @
6b02f8ca
...
@@ -45,7 +45,8 @@ def function_dump(filename, inputs, outputs=None, mode=None, updates=None,
...
@@ -45,7 +45,8 @@ def function_dump(filename, inputs, outputs=None, mode=None, updates=None,
To load such a dump and do the compilation:
To load such a dump and do the compilation:
>>> import cPickle, theano
>>> from six.moves import cPickle
>>> import theano
>>> d = cPickle.load(open("func_dump.bin", "rb")) # doctest: +SKIP
>>> d = cPickle.load(open("func_dump.bin", "rb")) # doctest: +SKIP
>>> f = theano.function(**d) # doctest: +SKIP
>>> f = theano.function(**d) # doctest: +SKIP
...
...
theano/misc/pkl_utils.py
浏览文件 @
6b02f8ca
...
@@ -327,13 +327,13 @@ def dump(obj, file_handler, protocol=DEFAULT_PROTOCOL,
...
@@ -327,13 +327,13 @@ def dump(obj, file_handler, protocol=DEFAULT_PROTOCOL,
>>> import theano
>>> import theano
>>> foo_1 = theano.shared(0, name='foo')
>>> foo_1 = theano.shared(0, name='foo')
>>> foo_2 = theano.shared(1, name='foo')
>>> foo_2 = theano.shared(1, name='foo')
>>> with open('model.zip', 'w') as f:
>>> with open('model.zip', 'w
b
') as f:
... dump((foo_1, foo_2, numpy.array(2)), f)
... dump((foo_1, foo_2, numpy.array(2)), f)
>>> numpy.load('model.zip').keys()
>>> numpy.load('model.zip').keys()
['foo', 'foo_2', 'array_0', 'pkl']
['foo', 'foo_2', 'array_0', 'pkl']
>>> numpy.load('model.zip')['foo']
>>> numpy.load('model.zip')['foo']
array(0)
array(0)
>>> with open('model.zip') as f:
>>> with open('model.zip'
, 'rb'
) as f:
... foo_1, foo_2, array = load(f)
... foo_1, foo_2, array = load(f)
>>> array
>>> array
array(2)
array(2)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论