tensorflow / skflow

Simplified interface for TensorFlow (mimicking Scikit Learn) for Deep Learning
Apache License 2.0
3.18k stars 439 forks source link

'module' object has no attribute 'rnn_cell' #98

Closed metjush closed 8 years ago

metjush commented 8 years ago

I'm trying the tutorial on Medium (https://medium.com/@ilblackdragon/tensorflow-tutorial-part-2-9ffe47049c92#.608vwpu2a) and the first DNN have raised this error:

Traceback (most recent call last):
  File "skflow_test.py", line 32, in <module>
    deep.fit(X_train, y_train)
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/estimators/base.py", line 189, in fit
    self._setup_training()
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/estimators/base.py", line 128, in _setup_training
    self._inp, self._out)
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/estimators/dnn.py", line 76, in _model_fn
    models.logistic_regression)(X, y)
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/models.py", line 91, in dnn_estimator
    layers = dnn(X, hidden_units)
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/ops/dnn_ops.py", line 39, in dnn
    tensor_in = tf.nn.rnn_cell.linear(tensor_in, n_units, True)
AttributeError: 'module' object has no attribute 'rnn_cell'

Is this a problem with my tensorflow installation? Or is there something different amiss? I have an up-to-date installation of TF, this is what happens when I run pip install tensorflow --upgrade:

Requirement already up-to-date: tensorflow in /Users/metjush/anaconda/lib/python2.7/site-packages
Requirement already up-to-date: six>=1.10.0 in /Users/metjush/anaconda/lib/python2.7/site-packages (from tensorflow)
Requirement already up-to-date: numpy>=1.9.2 in /Users/metjush/anaconda/lib/python2.7/site-packages (from tensorflow)

This is my Python setup:

Python 2.7.10 |Anaconda 2.3.0 (x86_64)| (default, Sep 15 2015, 14:29:08) 
[GCC 4.2.1 (Apple Inc. build 5577)] on darwin
ilblackdragon commented 8 years ago

Which version of tensorflow do you have? This seems like an issue with using 0.5 version.

You can try updating tensorflow by doing this:

pip uninstall tensorflow
pip install --upgrade https://storage.googleapis.com/tensorflow/linux/cpu/tensorflow-0.6.0-cp27-none-linux_x86_64.whl
pcrease commented 8 years ago

I just had the same issue as @metjush, and discovered I had version 0.5.0 of TensorFlow. After upgrading to 0.6.0 the example above then ran as expected, so this solved the problem. :-)

metjush commented 8 years ago

Thanks both. I updated tensorflow to 0.6.0. It now raises a different error:

RuntimeError: module compiled against API version a but this version of numpy is 9
Traceback (most recent call last):
  File "skflow_test.py", line 3, in <module>
    import skflow
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/skflow/__init__.py", line 17, in <module>
    import tensorflow as tf
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/__init__.py", line 23, in <module>
    from tensorflow.python import *
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/__init__.py", line 50, in <module>
    from tensorflow.python.framework.framework_lib import *
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/framework_lib.py", line 62, in <module>
    from tensorflow.python.framework.ops import Graph
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 40, in <module>
    from tensorflow.python.framework import versions
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/framework/versions.py", line 24, in <module>
    from tensorflow.python import pywrap_tensorflow
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 28, in <module>
    _pywrap_tensorflow = swig_import_helper()
  File "/Users/metjush/anaconda/lib/python2.7/site-packages/tensorflow/python/pywrap_tensorflow.py", line 24, in swig_import_helper
    _mod = imp.load_module('_pywrap_tensorflow', fp, pathname, description)
ImportError: numpy.core.multiarray failed to import

It is trying to load numpy from a different python distribution, not anaconda (even though I run it with the python command from anaconda). I can't seem to make it load the right one.

terrytangyuan commented 8 years ago

@metjush See this for potential solution: http://stackoverflow.com/questions/20518632/importerror-numpy-core-multiarray-failed-to-import

Should be able to load correctly if numpy version is correct. Thanks.