首页 文章

Theano继续训练

提问于
浏览
0

我正在寻找关于如何在theano继续训练的一些建议 . 例如,我有以下内容:

classifier = my_classifier()

cost = ()
updates = []
train_model = theano.function(...)
eval_model = theano.function(...)

best_accuracy = 0
while (epoch < n_epochs):

    train_model()

    current_accuracy = eval_model()
    if current_accuracy > best_accuracy:
        save classifier or save theano functions?
        best_accuracy = current_accuracy
    else:
        load saved classifier or save theano functions?
        if we saved classifier previously, do we need to redefine train_model and eval_model functions?

    epoch+=1

#training is finished
save classifier

我想保存当前训练的模型,如果它具有比先前训练的模型更高的精度,并且如果当前训练的模型精度低于最佳精度则加载所保存的模型 .

我的问题是:

保存时,我应该保存分类器还是theano功能?

如果需要保存分类器,我是否需要在加载时重新定义theano函数,因为分类器已更改 .

谢谢,

1 回答

  • 0

    当酸洗模型时,最好保存参数,并在加载时重新创建共享变量并重建图形 . 这允许在CPU和GPU之间交换设备 .

    但是你可以腌制Theano的功能 . 如果你这样做,同时腌制所有相关的功能 . 否则,它们将使每个共享变量的副本不同 . 每次调用load()都会创建新的共享变量(如果它们在哪里被pickle) . 这是泡菜的限制 .

相关问题