Search code examples
pythonpython-3.xtensorflowkeraskeras-layer

from ..layers import Input SystemError: Parent module '' not loaded, cannot perform relative import


I'm trying to run resnet50.py from keras.applications but i get this error:

    from ..layers import Input
SystemError: Parent module '' not loaded, cannot perform relative import

pls tell me how to fix it?


Solution

  • It appears that resnet50.py is a part of the keras package and is not meant to be run as a standalone script by itself.

    I would recommend importing the relevant classes from the resnet50 package. For example, you could do something like:

    from keras.applications.resnet50 import ResNet50
    
    resnet = ResNet50(...)
    

    Of course, you would need to install keras first.