AttributeError: 'Node' object has no attribute 'output_masks'

后端 未结 4 1935
情歌与酒
情歌与酒 2021-01-04 08:02

I use Keras pretrained model VGG16. The problem is that after configuring tensorflow to use the GPU I get an error that I didn\'t have before when using the CPU.

The

相关标签:
4条回答
  • 2021-01-04 08:35

    I had a similar issue, but with different architecture. As people suggested, it's important not to mix keras with tensorflow.keras, so try swapping code like:

    from keras.preprocessing import image
    from keras.models import Model
    from keras.layers import Dense, GlobalAveragePooling2D
    from keras import backend as K
    

    to:

    from tensorflow.keras.preprocessing import image 
    from tensorflow.keras.models import Model 
    from tensorflow.keras.layers import Dense, GlobalAveragePooling2D 
    from tensorflow.keras import backend as K
    

    Also make sure, you don't use keras.something inside your code (not only imports) as well, hope it helps : ) Also, I used Keras 2.2.4 with tensorflow 1.10.0

    0 讨论(0)
  • 2021-01-04 08:45

    I had the same error when I import keras and tenerflow.keras simultaneously: from tensorflow.keras.optimizers import Adam from keras.utils import multi_gpu_model

    I solved this problem after changing the code into: from tensorflow.keras.optimizers import Adam from tensorflow.keras.utils import multi_gpu_model

    0 讨论(0)
  • 2021-01-04 08:45

    if you are importing VGG16 from tensorflow.keras.applications.vgg16 then import all models from tensorflow

    from tensorflow.keras.applications.vgg16 import VGG16
    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Dense, Dropout, Flatten
    

    elif you are importing from keras like:

    from keras.applications.vgg16 import VGG16
    

    then use model import from keras

    from keras.models import Sequential
    from keras.layers import Dense
    
    0 讨论(0)
  • 2021-01-04 08:46

    You're likely importing tf.keras.layers or tf.keras.applications or other keras modules from tensorflow.keras, and mixing these objects with objects from the "pure" keras package, which is not compatible, based upon version, etc.

    I recommend seeing if you can import and run everything from the "pure" keras modules; don't use tf.keras while debugging, as they're not necessarily compatible. I had the same problem, and this solution is working for me.

    0 讨论(0)
提交回复
热议问题