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

wide_n_deep Tutorial example not working #6184

Closed
KK78 opened this Issue Dec 8, 2016 · 24 comments

Comments

Projects
None yet
@KK78

KK78 commented Dec 8, 2016

Windows 10 - 0.12.0-rc0

Encountered error "AttributeError: 'NoneType' object has no attribute 'bucketize'" when running the example without any modification.

Full working and error log as follows:

WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01.
WARNING:tensorflow:From C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and 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(...))
WARNING:tensorflow:From C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and 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(...))
WARNING:tensorflow:From C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and 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(...))
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.
Traceback (most recent call last):
File "wide_n_deep_tutorial.py", line 207, in
tf.app.run()
File "C:\Python35\lib\site-packages\tensorflow\python\platform\app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "wide_n_deep_tutorial.py", line 203, in main
train_and_eval()
File "wide_n_deep_tutorial.py", line 196, in train_and_eval
m.fit(input_fn=lambda: input_fn(df_train), steps=FLAGS.train_steps)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py", line 711, in fit
max_steps=max_steps)
File "C:\Python35\lib\site-packages\tensorflow\python\util\deprecation.py", line 191, in new_func
return func(*args, **kwargs)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 355, in fit
max_steps=max_steps)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 699, in _train_model
train_ops = self._get_train_ops(features, labels)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1052, in _get_train_ops
return self._call_model_fn(features, labels, model_fn_lib.ModeKeys.TRAIN)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py", line 1019, in _call_model_fn
params=self.params)
File "C:\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py", line 504, in _dnn_linear_combined_model_fn
scope=scope)
File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\feature_column_ops.py", line 526, in weighted_sum_from_feature_columns
transformed_tensor = transformer.transform(column)
File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\feature_column_ops.py", line 869, in transform
feature_column.insert_transformed_feature(self._columns_to_tensors)
File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\layers\feature_column.py", line 1489, in insert_transformed_feature
name="bucketize")
File "C:\Python35\lib\site-packages\tensorflow\contrib\layers\python\ops\bucketization_op.py", line 48, in bucketize
return _bucketization_op.bucketize(input_tensor, boundaries, name=name)
AttributeError: 'NoneType' object has no attribute 'bucketize'

@KK78

This comment has been minimized.

KK78 commented Dec 14, 2016

I have traced back the error to "_bucketization_op.py". There is a line of code that says
"_bucketization_op = loader.load_op_library(
resource_loader.get_path_to_datafile("_bucketization_op.so"))"

I could not find the file "_bucketization_op.so" in my TensorFlow installation for Windows 10. Is "_bucketization_op.so" supposed to be in the installation directory?

Thank you.

@prodipta

This comment has been minimized.

prodipta commented Dec 15, 2016

I have a similar issue. My installation is tensorflow version 0.12.0rc1, on Python 3.5.2 :: Anaconda 4.2.0 (64-bit) on Windows 10.

`File "C:\Users\Prodipta\Anaconda3\lib\site-packages\tensorflow\contrib\layers\python\ops\bucketization_op.py", line 48, in bucketize
    return _bucketization_op.bucketize(input_tensor, boundaries, name=name)
AttributeError: 'NoneType' object has no attribute 'bucketize'`

The function call (in the bucketization_op.py) get_path_to_datafile("_bucketization_op.so") just returns "_bucketization_op.so" (object type str). The file itself does not seem to exist.

The code runs fine removing the bucketization and the column crossing. (Also, I had to make some changes on the input_fn definition from dense_shape=[df[k].size, 1] to just shape=[df[k].size, 1])

@PseudoDesign

This comment has been minimized.

PseudoDesign commented Dec 15, 2016

I'm having a similar issue. Tensorflow 0.12.0rc1, Python 3.5.2, Windows 10

WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "sum" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:The default value of combiner will change from "mean" to "sqrtn" after 2016/11/01. WARNING:tensorflow:From C:\Program Files\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with x is deprecated and 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(...)) WARNING:tensorflow:From C:\Program Files\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with y is deprecated and 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(...)) WARNING:tensorflow:From C:\Program Files\Python35\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py:711 in fit.: calling BaseEstimator.fit (from tensorflow.contrib.learn.python.learn.estimators.estimator) with batch_size is deprecated and 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(...)) Traceback (most recent call last): File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 578, in merge_with self.assert_same_rank(other) File "C:\Program Files\Python35\lib\site-packages\tensorflow\python\framework\tensor_shape.py", line 624, in assert_same_rank "Shapes %s and %s must have the same rank" % (self, other)) ValueError: Shapes (0,) and (?, ?) must have the same rank

@jangsoopark

This comment has been minimized.

Contributor

jangsoopark commented Dec 15, 2016

On windows load_op_library doesn't have any action, just return None
(https://github.com/tensorflow/tensorflow/blob/5a5a25ea3ebef623e07fb9a46419a9df377a37a5/tensorflow/contrib/util/loader.py)

I found the message from this url 45c8386

In tf.contrib, only load external op libraries on non-Windows platforms.
This enables tf.contrib to be used on Windows, which does not currently
support the TensorFlow plugin mechanism.

@noahajohn

This comment has been minimized.

noahajohn commented Dec 22, 2016

Side question: any idea what's causing the warning:
WARNING:tensorflow:Rank of input Tensor (1) should be the same as output_rank (2) for column. Will attempt to expand dims. It is highly recommended that you resize your input, as this behavior may change.

Is there a way to prevent this and/or can it be ignored?

@mcnarik

This comment has been minimized.

mcnarik commented Jan 15, 2017

For someone who is searching as I was...

The tutorial has two issues (at least on windows installation):

  1. TypeError: init() got an unexpected keyword argument 'density_shape'
  2. AttributeError: 'NoneType' object has no attribute 'bucketize'

Temporary SOLUTION as follows:

Issue 1 - temp. solution
Change "density_shape" in following code:
categorical_cols = { k: tf.SparseTensor( indices=[[i, 0] for i in range(df[k].size)], values=df[k].values, density_shape=[df[k].size, 1]) for k in CATEGORICAL_COLUMNS}
To just "shape":
categorical_cols = { k: tf.SparseTensor( indices=[[i, 0] for i in range(df[k].size)], values=df[k].values, shape=[df[k].size, 1]) for k in CATEGORICAL_COLUMNS}

Issue 2 - temp. solution
Change model type from "wide" or "wide_n_deep" to "deep"

@caisq
Would be great if someone from responsible persons could comment the problems.
Is it just tutorial issue? Is it windows installation issue? Doe's it mean, this is general issue, therefore "wide_n_deep" model is unusable?

Thank you for your support

@prodipta

This comment has been minimized.

prodipta commented Jan 15, 2017

As I see it from my attempts, it is an windows version issue - they do not ship the DLLs for some shared libraries like they do the SOs for the Linux version. Better switch to the Linux version, it appears to work just fine.

@shadofren

This comment has been minimized.

shadofren commented Jan 15, 2017

@mcnarik I experience your problem 1 as well and I'm using linux, the parameter name on linux is dense_shape and should be changed to shape. I guess they forget to update the tutorial.

@prodipta

This comment has been minimized.

prodipta commented Jan 15, 2017

to be clear, the issues with windows is on the point 2, bucketize has no definition, the shared objects missing in windows.

@liuchbryan

This comment has been minimized.

liuchbryan commented Jan 16, 2017

@mcnarik @shadofren I believe "problem 1" is caused by the v1.0.0-alpha release (https://github.com/tensorflow/tensorflow/releases/tag/v1.0.0-alpha), in which they also changed the wide and deep tutorial to match the change of SparseTensor's argument from shape to dense_shape (see 056c087).

The wide and deep tutorial code in branch r0.12 (https://github.com/tensorflow/tensorflow/blob/r0.12/tensorflow/examples/learn/wide_n_deep_tutorial.py) runs on my machine (with Mac OS X 10.11.5, Python 2.7.12, and Tensorflow 0.12.1) - worth having a look!

Will leave problem 2 for those with better understanding.

@mcnarik

This comment has been minimized.

mcnarik commented Jan 16, 2017

@liuchbryan
The point 1 is clear but it makes sense to write it here together with solution because official tutorial is wrong and I spend a lot of time just searching for solution.

Regarding point 2. I know it works on different systems (Linux, Mac OS X) and I also test the example you shared. However from my point of view, installing a different system is not solution. I would like to use Windows because I know them much better and therefore can focus on neural networks and not on how to install and work with Linux. Since the tool should support Windows, I think this is valid expectation.
As mentioned by prodipta the issue on windows is in TensorFlow packages/classes for windows and should be therefore fixed (soon or later). But maybe I'm wrong...

Anyway, I really appriciate work of the developers and love the tool!

@liuchbryan

This comment has been minimized.

liuchbryan commented Jan 16, 2017

@mcnarik
Apologies if I did not made clear in my previous comment - the entire comment (bar from the last line) was solely dealing with issue/problem 1 you have mentioned. That is, you can also run the wide and deep tutorial code which lives in branch r0.12 if you only have access to the older Tensorflow 0.12, which should run without any error. On hindsight, we are essentially suggesting the same fix, and it is absolutely the right thing to do to suggest that temporary fix on here.

I am inclined not to say the official tutorial (here defined as: wide_n_deep_tutorial.py hosted on GitHub) is "wrong" - while it may be too ahead in time to be actually useful, it is consistent with Tensorflow's latest version (v1.0.0-alpha). On the other hand, I think we will agree the code shown in this blog post might need some verbose warning for the time being, and some update on the use of shape/dense_shape argument keyword in the future.

I totally agree your comment on the ability to use Tensorflow on Windows - it will be a shame if half the community is denied use simply because some libraries are missing!

Sorry for getting off-tangent, will leave the thread for the actual working for issue/problem 2.

@sajjo79

This comment has been minimized.

sajjo79 commented Feb 15, 2017

I got the same problem and doing two changes "dense_shape" to "shape" and "wide_n_deep" to "deep", it worked. However I received a bunch of warnings. Is it due to windows or I need to update my system?

@tomwanzek

This comment has been minimized.

tomwanzek commented Mar 2, 2017

Is there an update on whether this will be addressed, so the wide & deep model can be run on Windows?

The issue still replicates on Windows 10 (64bit), Anaconda 4.3.8 virtual environment with Python 3.5.3 and TensorFlow 1.0.0.

Running with the deep instead of the wide_n_deep flag, does not actually run the model of interest based on tf.contrib.learn.DNNLinearCombinedClassifier.

Thx in advance.

@junjunwangA

This comment has been minimized.

junjunwangA commented Mar 14, 2017

@tomwanzek, I followed the build for #8217 but It can not solve the issue

@techscientist

This comment has been minimized.

techscientist commented Mar 23, 2017

I'm also having the same problem...Any updates on this?

@tomwanzek

This comment has been minimized.

tomwanzek commented Mar 23, 2017

I just pulled down the last stable nightly build for Windows/GPU (114) (the later builds up to 122 have failed for GPU) and the Windows/CPU build (122). I can confirm that, the original issue still persists.

@mrry Thanks for all the hard work on TF 💯 Are you in a position to pin down, what remains to be done assuming that the now merged PR #8217 was one of the missing building blocks to a resolution?

@mrry

This comment has been minimized.

Contributor

mrry commented Mar 23, 2017

@tomwanzek I think the changes are fairly modest. There are two options:

  1. (More principled.) Convert the Wide&Deep-related ops to using @guschmue's newly-added tf.load_library() support, which will require some additions to the CMake build, similar to the ones Guenther did for tf.contrib.rnn in #8217.

  2. (Easier.) Convert the Python code in the Wide&Deep libraries to use statically generated Python wrappers, rather than getting them from the return value of tf.load_op_library(). We've already done this for several libraries (e.g. tf.contrib.tensor_forest in #6908).

@mrry

This comment has been minimized.

Contributor

mrry commented Mar 23, 2017

(EDIT: Interestingly, an internal change is pending to do option 2, so it might be easier to wait a couple days and the HEAD should just work.)

@tomwanzek

This comment has been minimized.

tomwanzek commented Mar 23, 2017

@mrry sounds great! Whatever option is more appropriate in light of the TF Roadmap...your call 👍

Only speaking for myself here: I'd rather wait a little longer and have a solution that is robust and consistent (beyond just wide & deep), than have a quick fix which outlives itself soon and implies different cognitive models for implementation of different models. Thx in advance.

@mrry

This comment has been minimized.

Contributor

mrry commented Mar 29, 2017

@tomwanzek The change I mentioned is now in, and I just sent a pull request to cherry-pick it into the 1.1 release. Therefore, if I'm not mistaken, you should be able to upgrade to a current nightly build or the next 1.1 release candidate (which should be out soon), and these ops will now work.

(Coincidentally, I just posted an answer on Stack Overflow that explains the whole sorry story, in case you're interested!)

@tomwanzek

This comment has been minimized.

tomwanzek commented Mar 29, 2017

@mrry Sounds great!!! I will give it a shot shortly as soon as they become available. I saw nightly 128 for Windows 10/GPU now references 1.1.0RC0. So I will give it a shot, although, based on you comment timing it might have to wait for the next stable nightly.

In any case, thanks a lot to yourself, @guschmue and everyone who chipped in on the windows load PR 💃

@tomwanzek

This comment has been minimized.

tomwanzek commented Mar 31, 2017

Just to confirm, I created a conda environment based on Windows/GPU Stable Build129 (1.1.0rc0 nightly) and the primary errors are indeed gone.

There are some remaining warnings related to deprecated API usage, but overall the wide and wide_n_deep models are runnable at this point!

So one more time: Cudos to @mrry and @guschmue .

@mrry

This comment has been minimized.

Contributor

mrry commented Mar 31, 2017

Thanks for confirming this, Tom!

@mrry mrry closed this Mar 31, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment