Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

module 'keras.engine' has no attribute 'Layer'

----> 6 from mrcnn.model import MaskRCNN

/usr/local/lib/python3.7/dist-packages/mrcnn/model.py in () 253 254 --> 255 class ProposalLayer(KE.Layer): 256 """Receives anchor scores and selects a subset to pass as proposals 257 to the second stage. Filtering is done based on anchor scores and

AttributeError: module 'keras.engine' has no attribute 'Layer'

like image 767
TAIFOUR TAOUTAOU Avatar asked Jun 09 '21 13:06

TAIFOUR TAOUTAOU


People also ask

Why is my keras import not working?

In essence, many of the import and attribute errors from keras come from the fact that keras changes its imports depending on whether you are using a CPU or using a GPU or ASIC. Some of the engine classes don’t get imported in every case. Instead, use from keras.layers import Layer and use that layer class in place of the one from the engine.

What are layers in keras?

Keras layers API. Layers are the basic building blocks of neural networks in Keras. A layer consists of a tensor-in tensor-out computation function (the layer's call method) and some state, held in TensorFlow variables (the layer's weights ). A Layer instance is callable, much like a function:

Why can't I use keras with TensorFlow?

Well, you are getting this error because of the compatibility issue between Tensorflow and Keras. You see under the hood Keras uses Tensorflow for various matrix manipulation.

Which module has no attribute 'load_weights_from_hdf5_group_by_name'?

module 'keras.engine.saving' has no attribute 'load_weights_from_hdf5_group_by_name' For lines where you are using Layers like ProposalLayer (KE.Layer)


1 Answers

This isn’t strictly a duplicate, but a similar question is found here: AttributeError: module 'keras.engine' has no attribute 'input_layer'

In essence, many of the import and attribute errors from keras come from the fact that keras changes its imports depending on whether you are using a CPU or using a GPU or ASIC. Some of the engine classes don’t get imported in every case.

Instead, use from keras.layers import Layer and use that layer class in place of the one from the engine.

like image 184
thshea Avatar answered Sep 30 '22 21:09

thshea