tensorflow 0.9 skflow模型保存和恢复不起作用

时间:2016-07-06 12:18:58

标签: python neural-network tensorflow skflow

我已经在python3上将我的张量流从0.7更新到0.9。现在我无法使用skflow(tensorflow.contrib.learn)恢复以前保存的模型。这是在tensorflow 0.7上工作的示例代码示例

import tensorflow.contrib.learn as skflow
from sklearn import datasets, metrics, preprocessing

boston = datasets.load_boston()
X = preprocessing.StandardScaler().fit_transform(boston.data)
regressor = skflow.TensorFlowLinearRegressor()
regressor.fit(X, boston.target)
score = metrics.mean_squared_error(regressor.predict(X), boston.target)
print ("MSE: %f" % score)

regressor.save('/home/model/')

classifier = skflow.TensorFlowEstimator.restore('/home/model/')

在tensorflow 0.9上,我收到了这个错误。

AttributeError: 'TensorFlowLinearRegressor' object has no attribute '_restore'

1 个答案:

答案 0 :(得分:0)

我相信在构建估算器/回归程序时,保存和恢复已被弃用,而不是model_dir参数:

regressor = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
regressor.fit(X, boston.target)
...
estimator = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
estimator.predict(...)