if os.path.exists(os.path.dirname(self.model_path)): if os.path.isfile(self.model_path): self.policy_network.load_state_dict(torch.load(self.model_path)) print("Loaded model from disk") else: os.makedirs(os.path.dirname(self.model_path))