1

I am trying to get a LinearRegressor to work and I get an error for which there doesn't seem to be much documentation about.

When I do:

regressor = tf.contrib.learn.LinearRegressor(feature_columns=linear_features)

regressor.fit(input_fn=training_input_fn, steps=10000)

regressor.evaluate(input_fn=eval_input_fn)

I get the error:

Instructions for updating: Please switch to tf.train.get_global_step

I am not sure how to proceed.

I read from the docs:

SOME ARGUMENTS ARE DEPRECATED. They will be removed after 2016-12-01. Instructions for updating: Estimator is decoupled from Scikit Learn interface by moving into separate class SKCompat. Arguments x, y and batch_size are only available in the SKCompat class, Estimator will only accept input_fn. Example conversion: est = Estimator(...) -> est = SKCompat(Estimator(...))

But I'm not sure to what I should change to, or how to switch to the global step.

I tried using tf.estimator.LinearRegressor mainly because I'm out of ideas, and did something like this:

estimator = tf.estimator.LinearRegressor(feature_columns=linear_features)

estimator.train(input_fn=training_input_fn)
estimator.evaluate(input_fn=eval_input_fn)
estimator.predict(input_fn=eval_input_fn)

But got no output at all.

Maxim
  • 52,561
  • 27
  • 155
  • 209
Trufa
  • 39,971
  • 43
  • 126
  • 190

1 Answers1

0

Instructions for updating: Please switch to tf.train.get_global_step

Actually, this is not an error, but a warning. It's logged exactly because you're using contrib package (see this discussion, short summary: it's deprecated).

You should switch to the core tf.estimator API and that includes everything:

  • tf.estimator.LinearRegressor instead of tf.contrib.learn.LinearRegressor
  • tf.estimator.inputs.numpy_input_fn instead of tf.contrib.learn.io.numpy_input_fn
  • tf.feature_column.numeric_column instead of tf.contrib.layers.real_valued_column
  • ...

The reason for not seeing anything with the new Estimator is likely due to eval_input_fn function. Make sure you specify num_epochs=1, otherwise it will loop over the data set again and again during evaluation.

Maxim
  • 52,561
  • 27
  • 155
  • 209