__init __ () получил несколько значений для ключевого аргумента 'filters' TypeError при загрузке сохраненной модели в керасы - PullRequest
0 голосов
/ 21 февраля 2019

Я не знаю, что не так с моим кодом или есть какая-то ошибка в керасе?При загрузке моей сохраненной модели с диска я получаю эту ошибку:

__init__() got multiple values for keyword argument 'filters' TypeError

Это мой код для сохранения модели и загрузки обратно в оболочку

import h5py
keras_mnist_model = 'mobilenet_model_keras_.h5'
m.save(filepath = keras_mnist_model)

Код для загрузки модели с диска:

# from tensorflow.keras.models import load_model
from keras.models import load_model
model = load_model(filepath = keras_mnist_model)

полное сообщение об ошибке:

TypeError                                 Traceback (most recent call last)
<ipython-input-32-8b3b788ba66d> in <module>
      1 # from tensorflow.keras.models import load_model
      2 from keras.models import load_model
----> 3 model = load_model(filepath = keras_mnist_model)

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/saving.py in load_model(filepath, custom_objects, compile)
    417 
    418     # Arguments
--> 419         group: A pointer to a HDF5 group.
    420         name: A name of the attributes to load.
    421 

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/saving.py in _deserialize_model(f, custom_objects, compile)
    223         """Handles custom object lookup.
    224 
--> 225         # Arguments
    226             obj: object, dict, or list.
    227 

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/saving.py in model_from_config(config, custom_objects)
    456         save_attributes_to_hdf5_group(g, 'weight_names', weight_names)
    457         for name, val in zip(weight_names, weight_values):
--> 458             param_dset = g.create_dataset(name, val.shape,
    459                                           dtype=val.dtype)
    460             if not val.shape:

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/layers/__init__.py in deserialize(config, custom_objects)
     53                                     module_objects=globs,
     54                                     custom_objects=custom_objects,
---> 55                                     printable_module_name='layer')

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    143                     config['config'],
    144                     custom_objects=dict(list(_GLOBAL_CUSTOM_OBJECTS.items()) +
--> 145                                         list(custom_objects.items())))
    146             with CustomObjectScope(custom_objects):
    147                 return cls.from_config(config['config'])

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/network.py in from_config(cls, config, custom_objects)
   1020         # does not yet exist) are re-enqueued, and the process
   1021         # is repeated until all nodes are processed.
-> 1022         while unprocessed_nodes:
   1023             for layer_data in config['layers']:
   1024                 layer = created_layers[layer_data['name']]

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/network.py in process_layer(layer_data)
   1006             # Gather layer inputs.
   1007             inbound_nodes_data = layer_data['inbound_nodes']
-> 1008             for node_data in inbound_nodes_data:
   1009                 # We don't process nodes (i.e. make layer calls)
   1010                 # on the fly because the inbound node may not yet exist,

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/layers/__init__.py in deserialize(config, custom_objects)
     53                                     module_objects=globs,
     54                                     custom_objects=custom_objects,
---> 55                                     printable_module_name='layer')

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/utils/generic_utils.py in deserialize_keras_object(identifier, module_objects, custom_objects, printable_module_name)
    145                                         list(custom_objects.items())))
    146             with CustomObjectScope(custom_objects):
--> 147                 return cls.from_config(config['config'])
    148         else:
    149             # Then `cls` may be a function returning a class.

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/engine/base_layer.py in from_config(cls, config)
   1107             A layer instance.
   1108         """
-> 1109         return cls(**config)
   1110 
   1111     def count_params(self):

~/code/data-science/tflite_face_recognition/model/venv/lib/python3.6/site-packages/keras/layers/convolutional.py in __init__(self, kernel_size, strides, padding, depth_multiplier, data_format, activation, use_bias, depthwise_initializer, bias_initializer, depthwise_regularizer, bias_regularizer, activity_regularizer, depthwise_constraint, bias_constraint, **kwargs)
   1795             regularizer=self.depthwise_regularizer,
   1796             constraint=self.depthwise_constraint)
-> 1797 
   1798         if self.use_bias:
   1799             self.bias = self.add_weight(shape=(input_dim * self.depth_multiplier,),

TypeError: __init__() got multiple values for keyword argument 'filters'
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...