python - Tensorflow 1.3.0 NameError: name 'LinearRegressor' is not defined -


i following "get started" instruction on official website. https://www.tensorflow.org/get_started/

i have tried both virtualenv , pip native installment method. , tensorflow can imported @ time.

but when tf.estimator.linearregressor can not used. need link kind of path make apis started work?

the error is:

traceback (most recent call last):   file "/home/binwang/documents/learning_tensorflow/3_getting_started_with_tensorflow.py", line 13, in <module>     estimator = linearregressor(feature_columns=feature_columns) nameerror: name 'linearregressor' not defined 

the code is:

import tensorflow tf # numpy used load, manipulate , preprocess data. import numpy np  # declare list of features. have 1 numeric feature. there many # other types of columns more complicated , useful. feature_columns = [tf.feature_column.numeric_column("x", shape=[1])]  # estimator front end invoke training (fitting) , evaluation # (inference). there many predefined types linear regression, # linear classification, , many neural network classifiers , regressors. # following code provides estimator linear regression. estimator = tf.estimator.linearregressor(feature_columns=feature_columns)  # tensorflow provides many helper methods read , set data sets. # here use 2 data sets: 1 training , 1 evaluation # have tell function how many batches # of data (num_epochs) want , how big each batch should be. x_train = np.array([1., 2., 3., 4.]) y_train = np.array([0., -1., -2., -3.]) x_eval = np.array([2., 5., 8., 1.]) y_eval = np.array([-1.01, -4.1, -7, 0.]) input_fn = tf.estimator.inputs.numpy_input_fn(     {"x": x_train}, y_train, batch_size=4, num_epochs=none, shuffle=true) train_input_fn = tf.estimator.inputs.numpy_input_fn(     {"x": x_train}, y_train, batch_size=4, num_epochs=1000, shuffle=false) eval_input_fn = tf.estimator.inputs.numpy_input_fn(     {"x": x_eval}, y_eval, batch_size=4, num_epochs=1000, shuffle=false)  # can invoke 1000 training steps invoking  method , passing # training data set. estimator.train(input_fn=input_fn, steps=1000)  # here evaluate how our model did. train_metrics = estimator.evaluate(input_fn=train_input_fn) eval_metrics = estimator.evaluate(input_fn=eval_input_fn) print("train metrics: %r"% train_metrics) print("eval metrics: %r"% eval_metrics) 

thanks!

could not using tensorflow v1.3 ?

in v1.2 linearregressor in tf.contrib.learn api doc since v1.3 in api doc.

use following print version installed.

import tensorflow tf print(tf.__version__) 

Comments

Popular posts from this blog

What is happening when Matlab is starting a "parallel pool"? -

angular - DownloadURL return null in below code -

php - Cannot override Laravel Spark authentication with own implementation -