tensorflow tensorflow.contrib.learn.Estimator加载训练模型

时间:2017-04-21 04:11:34

标签: python-3.x tensorflow

我这样调用这个函数后:

    from tensorflow.contrib import learn
    #----------------------------------------
    #Do some process here
    #----------------------------------------
    classifier = learn.Estimator(model_fn=bag_of_words_model,model_dir='F:/data')
    classifier.fit(feature_train, target_train, steps=1000)

我的文件夹“F:/ data”中会有这样的文件 enter image description here

我想知道我还有重用这个模型吗?就像转移到新计算机并使用它来预测新数据一样。对不起,我的英语不好。感谢所有的答案!!希望你们都过得愉快。

1 个答案:

答案 0 :(得分:3)

在要重复使用模型的脚本中,再次重新定义/导入bag_of_words_model并定义

classifier_loaded = learn.Estimator(model_fn=bag_of_words_model, model_dir='F:/data')

Tensorflow将重新加载图表并将权重导入图表中,您可以将其用作

classifier_loaded.predict(input_fn=input_fn)

或继续培训

claissifier_loaded.fit(feature_train, target_train)
相关问题