Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
P
pytensor
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
testgroup
pytensor
Commits
be01a30d
提交
be01a30d
authored
7月 23, 2015
作者:
Iban Harlouchet
提交者:
Arnaud Bergeron
9月 08, 2015
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
testcode for doc/tutorial/loading_and_saving.txt
上级
e08c1dbd
显示空白字符变更
内嵌
并排
正在显示
1 个修改的文件
包含
7 行增加
和
6 行删除
+7
-6
loading_and_saving.txt
doc/tutorial/loading_and_saving.txt
+7
-6
没有找到文件。
doc/tutorial/loading_and_saving.txt
浏览文件 @
be01a30d
...
@@ -66,7 +66,7 @@ same order):
...
@@ -66,7 +66,7 @@ same order):
>>> f = file('objects.save', 'wb')
>>> f = file('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:
...
@@ -74,7 +74,7 @@ Then:
...
@@ -74,7 +74,7 @@ Then:
>>> f = file('objects.save', 'rb')
>>> f = file('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))
>>> f.close()
>>> f.close()
For more details about pickle's usage, see
For more details about pickle's usage, see
...
@@ -102,7 +102,7 @@ along every instance of your model.
...
@@ -102,7 +102,7 @@ along every instance of your model.
For instance, you can define functions along the lines of:
For instance, you can define functions along the lines of:
..
code-block:: python
..
testcode::
def __getstate__(self):
def __getstate__(self):
state = dict(self.__dict__)
state = dict(self.__dict__)
...
@@ -127,8 +127,9 @@ The main advantage of this approach is that you don't even need Theano installed
...
@@ -127,8 +127,9 @@ The main advantage of this approach is that you don't even need Theano installed
in order to look at the values of shared variables that you pickled. You can
in order to look at the values of shared variables that you pickled. You can
just load the parameters manually with `numpy`.
just load the parameters manually with `numpy`.
..
code-block:: python
..
testcode::
import numpy
numpy.load('model.zip')
numpy.load('model.zip')
This approach could be beneficial if you are sharing your model with people who
This approach could be beneficial if you are sharing your model with people who
...
@@ -153,7 +154,7 @@ don't.
...
@@ -153,7 +154,7 @@ don't.
For instance, if the only parameters you want to save are a weight
For instance, if the only parameters you want to save are a weight
matrix *W* and a bias *b*, you can define:
matrix *W* and a bias *b*, you can define:
..
code-block:: python
..
testcode::
def __getstate__(self):
def __getstate__(self):
return (self.W, self.b)
return (self.W, self.b)
...
@@ -167,7 +168,7 @@ If at some point in time *W* is renamed to *weights* and *b* to
...
@@ -167,7 +168,7 @@ If at some point in time *W* is renamed to *weights* and *b* to
*bias*, the older pickled files will still be usable, if you update these
*bias*, the older pickled files will still be usable, if you update these
functions to reflect the change in name:
functions to reflect the change in name:
..
code-block:: python
..
testcode::
def __getstate__(self):
def __getstate__(self):
return (self.weights, self.bias)
return (self.weights, self.bias)
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论