【问题标题】:Saving, loading and predicting with Theano CNN (LeNet)使用 Theano CNN (LeNet) 进行保存、加载和预测
【发布时间】:2016-12-01 18:53:00
【问题描述】:

我正在寻找正确的方法来保存加载并对单个图像文件进行一些预测 strong> 使用 Theano CNN (LeNet) 训练模型。 我已经用 Theano LogisticRegression 和 MLP 做到了,效果很好。但我不知道如何使用 CNN 来做到这一点。 实际上,我不确定在保存过程中应该存储哪些参数,因为有更多层。

【问题讨论】:

    标签: machine-learning neural-network deep-learning theano conv-neural-network


    【解决方案1】:

    如果您的参数在共享变量 w、v、u 中,那么您的保存命令应该类似于:

    >>> 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)
    

    【讨论】:

      猜你喜欢
      • 2017-06-27
      • 2019-10-29
      • 1970-01-01
      • 1970-01-01
      • 2022-01-14
      • 2018-03-02
      • 1970-01-01
      • 1970-01-01
      • 2020-05-20
      相关资源
      最近更新 更多