Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

No module named layers

I'm using tensorflow 1.0.0 and I want to access the tensorflow.layers module. The module seems to exist:

In [12]: dir(tensorflow.layers)
Out[12]: 
['__builtins__',
 '__doc__',
 '__file__',
 '__name__',
 '__package__',
 '_allowed_symbols',
 'average_pooling1d',
 'average_pooling2d',
 'average_pooling3d',
 'batch_normalization',
 'conv1d',
 'conv2d',
 'conv2d_transpose',
 'conv3d',
 'dense',
 'dropout',
 'max_pooling1d',
 'max_pooling2d',
 'max_pooling3d',
 'separable_conv2d']

But when I try to import e.g. the dense function:

In [13]: from tensorflow.layers import dense
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)
<ipython-input-13-e5b2c910300d> in <module>()
----> 1 from tensorflow.layers import dense

ImportError: No module named layers

Why can python not access the module?

like image 385
eager2learn Avatar asked Nov 09 '22 01:11

eager2learn


1 Answers

Something is wrong with your installation or workspace:

  • Make sure you don’t have a directory called ‘tensorflow” in your Python Path.
  • Install again the official tensorflow distro pip install —upgrade —ignore-installed tensorflow)
  • Make sure you are using the right tensorflow version print(tensorflow.__version__)
like image 79
fabrizioM Avatar answered Nov 15 '22 08:11

fabrizioM