'Model' object has no attribute 'metrics_tensors' 问题解决!!!

出现错误:

Traceback (most recent call last):
  File "D:/PycharmProjects/安全帽目标检测/model.py", line 257, in <module>
    model.train(train_set, test_set, learning_rate=config.LEARNING_RATE, epochs=1000000, layers='heads')
  File "D:\PycharmProjects\安全帽目标检测\Mask_RCNN\mrcnn\model.py", line 2354, in train
    self.compile(learning_rate, self.config.LEARNING_MOMENTUM)
  File "D:\PycharmProjects\安全帽目标检测\Mask_RCNN\mrcnn\model.py", line 2199, in compile
    self.keras_model.metrics_tensors.append(loss)
AttributeError: 'Model' object has no attribute 'metrics_tensors'

keras 本地版本过高,三种解决办法,任选其一:
1、降低本地版本到2.2.5以下,当然要高于2.0.8
2、修改代码,将

self.keras_model.metrics_tensors.append(loss)

改成

self.keras_model.add_metric(loss, name)

3、初始化

self.keras_model.metrics_tensors = []

问题解决!!!

你可能感兴趣的:(python学习,python,深度学习)