J'ai une grande classe qui ressemble à la suivante:
class Trainer:
def __init__(self, name, age, height, weight):
self.name = name
self.age = age
self.height = height
self.weight = weight
def fit(self, dataloader):
....DO MODEL TRAINING...
self.save(path=xxx)
self.load(path=xxx)
def save(self, path):
self.model.eval()
torch.save(self.model.state_dict(), path)
@staticmethod
def load(path: str):
"""Load a model checkpoint from the given path."""
checkpoint = torch.load(path, map_location=torch.device("cpu"))
return checkpoint
À partir d' ici, je vois que depuis mon load()
n'a pas besoin de l'auto depuis dans le load
méthode, nous n'appelons pas de soi, alors nous devrions utiliser staticmethod
. Est-ce correct?