tensorflow 0.9 skflow 模型保存和恢复不起作用
tensorflow 0.9 skflow model save and restore doesn't work
我已经在 python3.And 上将我的 tensorflow 从 0.7 更新到 0.9,现在我无法使用 skflow (tensorflow.contrib.learn) 恢复我以前保存的模型。这里是工作过的示例代码示例张量流 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'
我相信在构建 estimator/regressor 时,保存和恢复已被弃用,取而代之的是 model_dir
参数:
regressor = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
regressor.fit(X, boston.target)
...
estimator = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
estimator.predict(...)
我已经在 python3.And 上将我的 tensorflow 从 0.7 更新到 0.9,现在我无法使用 skflow (tensorflow.contrib.learn) 恢复我以前保存的模型。这里是工作过的示例代码示例张量流 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'
我相信在构建 estimator/regressor 时,保存和恢复已被弃用,取而代之的是 model_dir
参数:
regressor = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
regressor.fit(X, boston.target)
...
estimator = skflow.TensorFlowLinearRegressor(model_dir='/home/model/')
estimator.predict(...)