我使用pytorch_image_classification来训练我的数据集,当我想使用evaluate.py来测试我的模型时,我得到了“TypeError: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
目前没有回答
相关问题 更多 >
编程相关推荐