def createMemento(self): filename = Utils.generateRandomString(16) + ".pt" path = os.path.join(self.checkPointPath, filename) if not os.path.exists(self.checkPointPath): os.mkdir(self.checkPointPath) torch.save(self.state_dict(), path) agentMemento = path return agentMemento
def append(self, storeField): assert isinstance(storeField, StoreField) dataToSave = { "buildParameterKey": storeField.buildParameterKey, "buildParameterLabel": storeField.buildParameterLabel, "buildParameterMemento": storeField.buildParameterMemento, "agentMemento": storeField.agentMemento, "epoch": storeField.epoch } trainLogFilePath = os.path.join(self.trainLogFolderPath, Utils.generateRandomString(16)) with open(trainLogFilePath, "w") as fp: json.dump(dataToSave, fp)