when I call torch.save() to save my model , it throws a FileNotFoundError. the trace back is as follow:

image1078×304 17.3 KB

Following is my code.
        def save_checkpoint(self, ckpt_dir, epoch):
        #self.hparams['dataset_name'] = Iris
        #f'{self.name}_{self.file_name} = iris_model_mlp
        path = os.path.join(
            ckpt_dir, self.hparams['dataset_name'], f'{self.name}_{self.file_name}')

        print(path)
        if not os.path.exists(ckpt_dir):
            os.makedirs(ckpt_dir)

        torch.save({'state': self.net.state_dict(),
                    'epoch': epoch,
                    'loss': self.loss_dict,
                    'optimizer': self.optimizer.state_dict(),
                    'scheduler': self.scheduler.state_dict()}, path , _use_new_zipfile_serialization= False)

        print(f'=> saved the model {self.file_name} to {path}')
        return path

Any Insights are helpful!!!
Torch version - 1.7.1