我正在寻找一种正确的方法来保存,load,并在单个图像文件上制作一些预测,使用Theano CNN (LeNet)训练的模型。我已经做了西亚诺LogisticRegression和MLP,它工作得很好。但我找不出CNN怎么做。实际上,我不确定在保存过程中应该存储哪些参数,因为有更多的层。
发布于 2016-08-26 16:51:44
如果您的参数位于共享变量w、v、u中,那么save命令应该如下所示:
>>> import cPickle
>>> save_file = open('path', 'wb') # this will overwrite current contents
>>> cPickle.dump(w.get_value(borrow=True), save_file, -1) # the -1 is for HIGHEST_PROTOCOL
>>> cPickle.dump(v.get_value(borrow=True), save_file, -1) # .. and it triggers much more efficient
>>> cPickle.dump(u.get_value(borrow=True), save_file, -1) # .. storage than numpy's default
>>> save_file.close()然后,您可以像这样加载数据:
>>> save_file = open('path')
>>> w.set_value(cPickle.load(save_file), borrow=True)
>>> v.set_value(cPickle.load(save_file), borrow=True)
>>> u.set_value(cPickle.load(save_file), borrow=True)https://stackoverflow.com/questions/38618426
复制相似问题