1
$\begingroup$

I'm new to TensorFlow and currently I'm trying to implement an LSTM using jupyter notebook.

But when I run the following code segment, I got some errors and couldn't find any solution.

How can I work through this error?

Code:

lstmCell = tf.contrib.rnn.BasicLSTMCell(lstmUnits)
lstmCell = tf.contrib.rnn.DropoutWrapper(cell=lstmCell, output_keep_prob=0.75)
value, _ = tf.nn.dynamic_rnn(lstmCell, data, dtype=tf.float32)

Error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-29-db6a6fc2c55e> in <module>()
----> 1 lstmCell = tf.contrib.rnn.BasicLSTMCell(lstmUnits)
      2 lstmCell = tf.contrib.rnn.DropoutWrapper(cell=lstmCell, output_keep_prob=0.75)
      3 value, _ = tf.nn.dynamic_rnn(lstmCell, data, dtype=tf.float32)

C:\Anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in __getattr__(self, item)
     51 
     52   def __getattr__(self, item):
---> 53     module = self._load()
     54     return getattr(module, item)
     55 

C:\Anaconda3\lib\site-packages\tensorflow\python\util\lazy_loader.py in _load(self)
     40   def _load(self):
     41     # Import the target module and insert it into the parent's namespace
---> 42     module = importlib.import_module(self.__name__)
     43     self._parent_module_globals[self._local_name] = module
     44 

C:\Anaconda3\lib\importlib\__init__.py in import_module(name, package)
    124                 break
    125             level += 1
--> 126     return _bootstrap._gcd_import(name[level:], package, level)
    127 
    128 

C:\Anaconda3\lib\importlib\_bootstrap.py in _gcd_import(name, package, level)

C:\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load(name, import_)

C:\Anaconda3\lib\importlib\_bootstrap.py in _find_and_load_unlocked(name, import_)

C:\Anaconda3\lib\importlib\_bootstrap.py in _load_unlocked(spec)

C:\Anaconda3\lib\importlib\_bootstrap_external.py in exec_module(self, module)

C:\Anaconda3\lib\importlib\_bootstrap.py in _call_with_frames_removed(f, *args, **kwds)

C:\Anaconda3\lib\site-packages\tensorflow\contrib\__init__.py in <module>()
     29 from tensorflow.contrib import data
     30 from tensorflow.contrib import deprecated
---> 31 from tensorflow.contrib import distributions
     32 from tensorflow.contrib import estimator
     33 from tensorflow.contrib import factorization

C:\Anaconda3\lib\site-packages\tensorflow\contrib\distributions\__init__.py in <module>()
     31 from tensorflow.contrib.distributions.python.ops.distribution_util import matrix_diag_transform
     32 from tensorflow.contrib.distributions.python.ops.distribution_util import softplus_inverse
---> 33 from tensorflow.contrib.distributions.python.ops.estimator import *
     34 from tensorflow.contrib.distributions.python.ops.geometric import *
     35 from tensorflow.contrib.distributions.python.ops.independent import *

C:\Anaconda3\lib\site-packages\tensorflow\contrib\distributions\python\ops\estimator.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 from tensorflow.contrib.learn.python.learn.estimators.head import _compute_weighted_loss
     22 from tensorflow.contrib.learn.python.learn.estimators.head import _RegressionHead
     23 from tensorflow.python.framework import ops

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\__init__.py in <module>()
     90 
     91 # pylint: disable=wildcard-import
---> 92 from tensorflow.contrib.learn.python.learn import *
     93 # pylint: enable=wildcard-import
     94 

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\__init__.py in <module>()
     21 
     22 # pylint: disable=wildcard-import
---> 23 from tensorflow.contrib.learn.python.learn import *
     24 # pylint: enable=wildcard-import

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\__init__.py in <module>()
     23 from tensorflow.contrib.learn.python.learn import basic_session_run_hooks
     24 from tensorflow.contrib.learn.python.learn import datasets
---> 25 from tensorflow.contrib.learn.python.learn import estimators
     26 from tensorflow.contrib.learn.python.learn import graph_actions
     27 from tensorflow.contrib.learn.python.learn import learn_io as io

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\__init__.py in <module>()
    295 from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
    296 from tensorflow.contrib.learn.python.learn.estimators.constants import ProblemType
--> 297 from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNClassifier
    298 from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNEstimator
    299 from tensorflow.contrib.learn.python.learn.estimators.dnn import DNNRegressor

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn.py in <module>()
     28 from tensorflow.contrib.layers.python.layers import optimizers
     29 from tensorflow.contrib.learn.python.learn import metric_spec
---> 30 from tensorflow.contrib.learn.python.learn.estimators import dnn_linear_combined
     31 from tensorflow.contrib.learn.python.learn.estimators import estimator
     32 from tensorflow.contrib.learn.python.learn.estimators import head as head_lib

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\dnn_linear_combined.py in <module>()
     29 from tensorflow.contrib.layers.python.layers import optimizers
     30 from tensorflow.contrib.learn.python.learn import metric_spec
---> 31 from tensorflow.contrib.learn.python.learn.estimators import estimator
     32 from tensorflow.contrib.learn.python.learn.estimators import head as head_lib
     33 from tensorflow.contrib.learn.python.learn.estimators import model_fn

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\estimators\estimator.py in <module>()
     47 from tensorflow.contrib.learn.python.learn.estimators import tensor_signature
     48 from tensorflow.contrib.learn.python.learn.estimators._sklearn import NotFittedError
---> 49 from tensorflow.contrib.learn.python.learn.learn_io import data_feeder
     50 from tensorflow.contrib.learn.python.learn.utils import export
     51 from tensorflow.contrib.learn.python.learn.utils import saved_model_export_utils

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\learn_io\__init__.py in <module>()
     19 from __future__ import print_function
     20 
---> 21 from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_data
     22 from tensorflow.contrib.learn.python.learn.learn_io.dask_io import extract_dask_labels
     23 from tensorflow.contrib.learn.python.learn.learn_io.dask_io import HAS_DASK

C:\Anaconda3\lib\site-packages\tensorflow\contrib\learn\python\learn\learn_io\dask_io.py in <module>()
     24 try:
     25   # pylint: disable=g-import-not-at-top
---> 26   import dask.dataframe as dd
     27   allowed_classes = (dd.Series, dd.DataFrame)
     28   HAS_DASK = True

C:\Anaconda3\lib\site-packages\dask\dataframe\__init__.py in <module>()
      1 from __future__ import print_function, division, absolute_import
      2 
----> 3 from .core import (DataFrame, Series, Index, _Frame, map_partitions,
      4                    repartition, to_delayed, to_datetime, to_timedelta)
      5 from .groupby import Aggregation

C:\Anaconda3\lib\site-packages\dask\dataframe\core.py in <module>()
     38 if PANDAS_VERSION >= '0.20.0':
     39     from pandas.util import cache_readonly
---> 40     pd.core.computation.expressions.set_use_numexpr(False)
     41 else:
     42     from pandas.util.decorators import cache_readonly

AttributeError: module 'pandas.core.computation' has no attribute 'expressions'
  • Tensorflow version - '1.4.0'
  • Python version - 3.6.3:: Anaconda, Inc.
$\endgroup$
1
$\begingroup$

Based on the solution here you have different choices:

The simplest solution is to revert back to Pandas 0.19.2. For this purpose use the following command in your command line or terminal.

conda install pandas=0.19.2
| improve this answer | |
$\endgroup$
  • $\begingroup$ revert back didn't work. but update dask solved the issue $\endgroup$ – Achira Shamal Jan 21 '18 at 16:10
  • $\begingroup$ @AchiraShamal so I'm so happy for you :) $\endgroup$ – Media Jan 21 '18 at 16:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.