AttributeError:模块'tensorflow.python.estimator.estimator_lib'没有属性'LinearRegressor'

Cel*_*eLi 6 attributeerror python-3.x tensorflow

import tensorflow as tf
import numpy as np
feature_columns = [tf.feature_column.numeric_column("x", shape=[1])]
estimator = tf.estimator.LinearRegressor(feature_columns=feature_columns)
Run Code Online (Sandbox Code Playgroud)

我的代码在上面.然后它显示错误

"AttributeError:module'tensorflow.python.estimator.estimator_lib'没有属性'LinearRegressor'"

Python 3.5.2

Ish*_*nal 17

可能是你正在使用旧的tensorflow版本,tf.estimator.LinearRegressor包括在内tensorflow=1.3.0.

升级tensorflow安装

pip install --upgrade tensorflow==1.3.0
Run Code Online (Sandbox Code Playgroud)