Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
2c1f7d80
提交
2c1f7d80
authored
2月 15, 2016
作者:
hantek
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
python 3 compatibility
上级
f51b38b9
隐藏空白字符变更
内嵌
并排
正在显示
8 个修改的文件
包含
28 行增加
和
30 行删除
+28
-30
advanced_theano.txt
doc/cifarSC2011/advanced_theano.txt
+5
-5
install_windows.txt
doc/install_windows.txt
+3
-3
scan.txt
doc/library/scan.txt
+1
-1
examples.txt
doc/tutorial/examples.txt
+6
-6
loading_and_saving.txt
doc/tutorial/loading_and_saving.txt
+6
-9
printing_drawing.txt
doc/tutorial/printing_drawing.txt
+3
-3
function.py
theano/compile/function.py
+2
-1
pkl_utils.py
theano/misc/pkl_utils.py
+2
-2
没有找到文件。
doc/cifarSC2011/advanced_theano.txt
浏览文件 @
2c1f7d80
...
@@ -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/install_windows.txt
浏览文件 @
2c1f7d80
...
@@ -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
浏览文件 @
2c1f7d80
...
@@ -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/examples.txt
浏览文件 @
2c1f7d80
...
@@ -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
浏览文件 @
2c1f7d80
...
@@ -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
浏览文件 @
2c1f7d80
...
@@ -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
|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]
...
...
theano/compile/function.py
浏览文件 @
2c1f7d80
...
@@ -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
浏览文件 @
2c1f7d80
...
@@ -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
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论