Я использовал пользовательский слой для моей модели Keras, а именно слой DepthwiseConv3D . Я обучил модель и сохранил ее, используя model.save("model.h5")
from DepthwiseConv3D import DepthwiseConv3D
model = load_model('model.h5',
custom_objects={'DepthwiseConv3D': DepthwiseConv3D})
Но я получаю «Ошибка типа: неупорядоченные типы: NoneType ()> int ()», вызванная DepthWiseConv3D в:
if (self.groups > self.input_dim):
raise ValueError('The number of groups cannot exceed the number of channels')
Конфигурация слоев:
def get_config(self):
config = super(DepthwiseConv3D, self).get_config()
config.pop('filters')
config.pop('kernel_initializer')
config.pop('kernel_regularizer')
config.pop('kernel_constraint')
config['depth_multiplier'] = self.depth_multiplier
config['depthwise_initializer'] = initializers.serialize(self.depthwise_initializer)
config['depthwise_regularizer'] = regularizers.serialize(self.depthwise_regularizer)
config['depthwise_constraint'] = constraints.serialize(self.depthwise_constraint)
return config
Я создал свой слой как
x = DepthwiseConv3D(kernel_size=(7,7,7),
depth_multiplier=1,groups=9,
padding ="same", use_bias=False,
input_shape=(50, 37, 25, 9))(x)
x = DepthwiseConv3D(depth_multiplier= 32, groups=8, kernel_size=(7,7,7),
strides=(2,2,2), activation='relu', padding = "same")(x)
x = DepthwiseConv3D(depth_multiplier= 64, groups=8, kernel_size=(7,7,7),
strides=(2,2,2), activation='relu', padding = "same")(x)
Как я могу загрузить свою модель?