代码之家  ›  专栏  ›  技术社区  ›  Paul Terwilliger

Tensorflow-如何复制估计器

  •  1
  • Paul Terwilliger  · 技术社区  · 7 年前

    使用tensorflow,我创建了一个 Estimator 命名的 my_estimator

    当我训练这个估计器时 my_estimator.train(...) 我的估计器内的权重改变了,我得到了不同的结果 my_estimator.predict(...) .

    有没有一种方法可以在训练之前将我的估计器模型保存到另一个名为 old_estimator 以便我能在训练前做出预测?我希望这次手术快点,所以如果我能把它保存在内存中就好了。

    我想这样的伪代码应该有用:

    # Do a prediction with our estimator
    prediction = next(my_estimator.predict(foo))
    
    # Copy the estimator - this is the function I'm looking for
    old_estimator = my_estimator.copy()
    
    # Train our estimator
    my_estimator.train(...)
    
    # Should be true
    next(old_estimator.predict(foo)) == prediction
    
    # Should be false
    next(old_estimator.predict(foo)) == next(my_estimator.predict(foo))
    
    0 回复  |  直到 7 年前