Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to solve AttributeError: module 'tensorflow.contrib.learn' has no attribute 'estimators' #69

Open
XutongLi opened this issue Jun 4, 2018 · 4 comments

Comments

@XutongLi
Copy link

XutongLi commented Jun 4, 2018

File "udc_predict.py", line 54, in
estimator._targets_info = tf.contrib.learn.estimator.tensor_signature.TensorSignature(tf.constant(0, shape=[1,1]))
AttributeError: module 'tensorflow.contrib.learn' has no attribute 'estimator'

@XutongLi
Copy link
Author

XutongLi commented Jun 5, 2018

i cannot find any useful solution _ORZ

@medasuryatej
Copy link

I did the following change, and some how it worked for me.
first, add this import command in "udc_predict.py"
from tensorflow.contrib.learn.python.learn.estimators import *

change the following line from
estimator._targets_info = tf.contrib.learn.estimators.tensor_signature.TensorSignature(tf.constant(0, shape=[1,1]))
to
estimator._targets_info = tensor_signature.TensorSignature(tf.constant(0, shape=[1,1]))

Also at the bottom, change the print command from
print("{}: {:g}".format(r, prob[0,0]))
to
print("{}: {:g}".format(r, next(prob)[0]))

Hope it helps. I am using Tensorflow Version 1.8, Python 3.6.5

@muba1
Copy link

muba1 commented May 9, 2019

having the similar issue in google colab? tf 2.0

feature_columns = tf.contrib.learn.infer_real_valued_columns_from_input_fn
module 'tensorflow' has no attribute 'contrib'

@cddypang
Copy link

cddypang commented Jul 28, 2019

  1. the error is in function 'create_model_fn' in udc_model.py,
    move "batch_size = targets.get_shape().as_list()[0]" after "if mode == tf.contrib.learn.ModeKeys.EVAL:" can fix this problem.

the reason is when in PREDICT mode, model_fn deal the param 'targets' as None.

  1. "prob = estimator.predict(input_fn=input_fn, as_iterable=False)" in cdc_predict.py,
    the param 'as_iterable' default value is True, change to False,
    the next line "prob[0,0]" can execute correct.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants