मैं एक बड़े वर्ग की तरह लग रहा है निम्नलिखित:
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
से यहाँ, मैं देख रहा हूँ कि जब से मेरी load()
की जरूरत नहीं है स्वयं के बाद से में load
विधि, हम फोन नहीं है, तो हम का उपयोग करना चाहिए staticmethod
. यह सही है?