model = ResNet50(weights='imagenet', include_top=False, input_shape = (150, 150, 3), pooling = 'max')
final_output = Dense(264, activation = 'softmax')(model.output)
model = Model(inputs = model.input, outputs = final_output)
这是我在colab中训练的模型。我试图在Kaggle中加载此错误,显示错误:“未知层:功能性”
完整追溯:
--------------------------------------------------- ---------------------------- ValueError追踪(最近的呼叫 最后) ----> 1个模型= tk.models.load_model('../ input / cornell-submission-model / resnet50_3.h5')
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/saving/save.py 在load_model(文件路径,custom_objects,编译) 第182章 183 isinstance(文件路径,h5py.File)或h5py.is_hdf5(文件路径))): -> 184返回hdf5_format.load_model_from_hdf5(文件路径,custom_objects,编译) 185 186 if sys.version_info> =(3,4)和isinstance(filepath,pathlib.Path):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/saving/hdf5_format.py 在load_model_from_hdf5中(文件路径,custom_objects,编译) (176)第265章 (177)第177章 -> 178个custom_objects = custom_objects) 179 180#设定砝码
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/saving/model_config.py 在model_from_config(config,custom_objects)中 53'
Sequential.from_config(config)
?') 来自tensorflow.python.keras.layers的54导入反序列化#pylint:disable = g-import-not-at-top ---> 55 return deserialize(config,custom_objects = custom_objects) 56 57/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/layers/serialization.py 在反序列化(config,custom_objects)中 107 module_objects = globs, 108 custom_objects = custom_objects, -> 109 printable_module_name ='layer')
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/utils/generic_utils.py 在deserialize_keras_object(identifier,module_objects, custom_objects,printable_module_name) 360 config =标识符 361(cls,cls_config)= class_and_config_for_serialized_keras_object( -> 362 config,module_objects,custom_objects,printable_module_name) 363 364如果hasattr(cls,'from_config'):
/opt/conda/lib/python3.7/site-packages/tensorflow/python/keras/utils/generic_utils.py 在class_and_config_for_serialized_keras_object(config, module_objects,custom_objects,printable_module_name) 319 cls = get_registered_object(类别名称,自定义对象,模块对象) 320如果cls为None: -> 321提高ValueError('Unknown'+ printable_module_name +':'+ class_name) 322 323 cls_config = config ['config']
ValueError:未知层:功能性
请帮助我
答案 0 :(得分:0)
ResNet50模型包含许多重复块。我对Colab并不熟悉,但是根据收到的错误,我的猜测是该图层块是作为 custom 图层实现的,因此您应该在custom_objects字典中定义并声明其实现