Closed leizh007 closed 1 month ago
run code in colab failed:
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)
[<ipython-input-2-5a10695a274f>](https://localhost:8080/#) in <cell line: 27>()
25 from keras.layers import Dropout
26 from keras.layers import Flatten
---> 27 from keras.constraints import maxnorm
28 from keras.layers.convolutional import Convolution2D
29 from keras.layers.convolutional import MaxPooling2D
ImportError: cannot import name 'maxnorm' from 'keras.constraints' (/usr/local/lib/python3.10/dist-packages/keras/constraints/__init__.py)
---------------------------------------------------------------------------
NOTE: If your import is failing due to a missing package, you can
manually install dependencies using either !pip or !apt.
To view examples of installing some common dependencies, click the
"Open Examples" button below.
---------------------------------------------------------------------------
run code in colab failed:
--------------------------------------------------------------------------- ImportError Traceback (most recent call last) [<ipython-input-2-5a10695a274f>](https://localhost:8080/#) in <cell line: 27>() 25 from keras.layers import Dropout 26 from keras.layers import Flatten ---> 27 from keras.constraints import maxnorm 28 from keras.layers.convolutional import Convolution2D 29 from keras.layers.convolutional import MaxPooling2D ImportError: cannot import name 'maxnorm' from 'keras.constraints' (/usr/local/lib/python3.10/dist-packages/keras/constraints/__init__.py) --------------------------------------------------------------------------- NOTE: If your import is failing due to a missing package, you can manually install dependencies using either !pip or !apt. To view examples of installing some common dependencies, click the "Open Examples" button below. ---------------------------------------------------------------------------
As the import error says, try installing the package first, before importing.
Traceback (most recent call last): File "/Users/leizh007/Downloads/ConvertMlmodellc/a.py", line 29, in
Model = load_model('/Users/leizh007/Downloads/ConvertMlmodellc/LightweightGCN-Model/LightweightGCN.h5')
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/saving/saving_api.py", line 189, in load_model
return legacy_h5_format.load_model_from_hdf5(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/legacy_h5_format.py", line 133, in load_model_from_hdf5
model = saving_utils.model_from_config(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/saving_utils.py", line 85, in model_from_config
return serialization.deserialize_keras_object(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py", line 495, in deserialize_keras_object
deserialized_obj = cls.from_config(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/models/model.py", line 521, in from_config
return functional_from_config(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/models/functional.py", line 477, in functional_from_config
process_layer(layer_data)
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/models/functional.py", line 457, in process_layer
layer = saving_utils.model_from_config(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/saving_utils.py", line 85, in model_from_config
return serialization.deserialize_keras_object(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py", line 473, in deserialize_keras_object
(cls, cls_config) = class_and_config_for_serialized_keras_object(
File "/opt/homebrew/lib/python3.10/site-packages/keras/src/legacy/saving/serialization.py", line 354, in class_and_config_for_serialized_keras_object
raise ValueError(
ValueError: Unknown layer: 'DeSubpixelConv2D'. Please ensure you are using a
keras.utils.custom_object_scope
and that this object is included in the scope. See https://www.tensorflow.org/guide/keras/save_and_serialize#registering_the_custom_object for details.