模型Mask_Rcnn训练错误:RuntimeError: It looks like you are subclassing 'Model'
一、问题:
最近在keras下利用两个GPU训练Mask_Rcnn模型的时候出现以下错误。
error:RuntimeError: It looks like you are subclassing 'Model'
and you forgot to call 'super(YourClass, self).__init__()'
二、解决方法:
在mrcnn/parallel_model.py文件中找到class ParallelModel(KM.Model),在类里面添加super(ParallelModel, self).__init__()
class ParallelModel(KM.Model):
def __init__(self, keras_model, gpu_count):
"""
Class constructor.
keras_model: The Keras model to parallelize
gpu_count: Number of GPUs. Must be > 1
"""
super(ParallelModel, self).__init__()
self.inner_model = keras_model
self.gpu_count = gpu_count
merged_outputs = self.make_parallel()
super(ParallelModel, self).__init__(inputs=self.inner_model.inputs, outputs=merged_outputs)

浙公网安备 33010602011771号