Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

ImportError: cannot import name 'transpose_shape'

I am following the Coursera, Deep Learning course with Andrew Ng for object detection with YOLO algorithm, I am trying to run the algorithm on my PC using Windows and Anaconda Navigator, I installed Keras to run on TensorFlow backend. But when I typed the following:

import tensorflow as tf
from keras import backend as K

It showed me the following:

Using TensorFlow backend.
Traceback (most recent call last):

  File "<ipython-input-8-0bcaeab92875>", line 2, in <module>
    from keras import backend as K

  File "C:\Users\AbanoubMamdouh\Anaconda3\lib\site-packages\keras\__init__.py", line 3, in <module>
    from . import utils

  File "C:\Users\AbanoubMamdouh\Anaconda3\lib\site-packages\keras\utils\__init__.py", line 6, in <module>
    from . import conv_utils

  File "C:\Users\AbanoubMamdouh\Anaconda3\lib\site-packages\keras\utils\conv_utils.py", line 9, in <module>
    from .. import backend as K

  File "C:\Users\AbanoubMamdouh\Anaconda3\lib\site-packages\keras\backend\__init__.py", line 89, in <module>
    from .tensorflow_backend import *

  File "C:\Users\AbanoubMamdouh\Anaconda3\lib\site-packages\keras\backend\tensorflow_backend.py", line 24, in <module>
    from ..utils.generic_utils import transpose_shape

ImportError: cannot import name 'transpose_shape'

Seems like it has a problem with this line in the tensorflow_backend.py file:

from ..utils.generic_utils import transpose_shape

Help would be much appreciated! Cheers

like image 223
Abanoub Mamdouh Avatar asked Nov 15 '18 22:11

Abanoub Mamdouh


2 Answers

Try to uninstall tensorflow and keras and install keras using pip, it also installs tensorflow. It worked for me!!!

like image 157
rahul gunda Avatar answered Nov 09 '22 18:11

rahul gunda


Probably a misconfiguration of the installed packages:

pip uninstall -y tensorflow keras tf-nightly keras-nightly

and then:

pip install tensorflow
like image 24
MobileCushion Avatar answered Nov 09 '22 18:11

MobileCushion