||
deeplearning.net/software/theano/tutorial/loading_and_saving.html
import cPickle
cPickle模块比较快
单个文件
#pickle object
f=file('obj.save','wb')
cPickle.dump(my_obj,f,protocol=cPickle.HIGHEST_PROTOCOL)
f.close()
#to load a pickled file
f=file('obj.save','rb')
loaded_obj=cPickle.load(f)
f.close()
多个文件
#pickle files
f=file('obj.save','wb')
for obj in [obj1,obj2,obj3]:
cPickle.dump(obj,f,protocol=cPickle.HIGHEST_PROTOCOL)
f.close()
#load files
f=file('obj.save','rb')
loaded_objs=[]
for i in range[3]:
loaded_objects.append(cPickle.load(f))
f.close()
Archiver|手机版|科学网 ( 京ICP备07017567号-12 )
GMT+8, 2024-12-22 11:12
Powered by ScienceNet.cn
Copyright © 2007- 中国科学报社