#python #pytorch
Вопрос:
Я использую pytorch_image_classification для обучения моего набора данных, когда я хочу использовать оценку.py чтобы проверить мою модель, я получил «Ошибка типа: add_checkpointable нужен объект с методом state_dict ()».
[введите описание изображения здесь][1]
Код приведен ниже:
checkpointer = Checkpointer(model,
checkpoint_dir=output_dir,
logger=logger,
distributed_rank=get_rank())
checkpointer.load(config.test.checkpoint)
def add_checkpointable(self, key: str, checkpointable: Any) -> None:
"""
Add checkpointable object for this checkpointer to track.
Args:
key (str): the key used to save the object
checkpointable: any object with ``state_dict()`` and
``load_state_dict()`` method
"""
if key in self.checkpointables:
raise KeyError(f"Key {key} already used in the Checkpointer")
if not hasattr(checkpointable, "state_dict"):
raise TypeError(
"add_checkpointable needs an object with 'state_dict()' method."
)
self.checkpointables[key] = checkpointable
Может кто-нибудь помочь мне, как решить .
[1]: https://i.stack.imgur.com/DSIc6.png
[2]: https://i.stack.imgur.com/ThAys.png
[3]: https://i.stack.imgur.com/KImKk.png
Комментарии:
1. Поместите в вопрос этот код, а не изображения