tf.estimator.LinearRegressor报错AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'LinearRegressor'
在使用TensorFlow中的模块tf.estimator.LinearRegressor时,报错如下所示:
Traceback (most recent call last):
File "D:/Python27/Lib/site-packages/django/bin/pylearn/deeplearning/tensorflow/tf9.py", line 8, in <module>
estimator = tf.estimator.LinearRegressor(feature_columns=feature_columns)
AttributeError: module 'tensorflow.python.estimator.estimator_lib' has no attribute 'LinearRegressor'
解决方案:
(1)将
estimator = tf.estimator.LinearRegressor(feature_columns=feature_columns)
替换为
estimator = tf.contrib.learn.LinearRegressor(feature_columns=feature_columns)
(2)如果用到 estimator.train( ),则替换为 estimator.fit()