Am o mare clasă, care arată în felul următor:
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
De aici, văd că de când mi-a load()
nu are nevoie de sine, deoarece în load
metoda, noi nu numim sine, atunci ar trebui să utilizați staticmethod
. Este acest lucru corect?