0

我正在尝试运行此代码https://towardsdatascience.com/detecting-heart-abnormalities-using-1d-cnn-on-data-you-cannot-see-with-pysyft-735481a952d8

class ECG(Dataset):
    # The class used to load the ECG dataset
    def __init__(self, mode='train'):
        if mode == 'train':
            with h5py.File(project_path/train_name, 'r') as hdf:
                self.x = torch.tensor(hdf['x_train'][:], dtype=torch.float)
                self.y = torch.tensor(hdf['y_train'][:])
        elif mode == 'test':
            with h5py.File(project_path/test_name, 'r') as hdf:
                self.x = torch.tensor(hdf['x_test'][:], dtype=torch.float)
                self.y = torch.tensor(hdf['y_test'][:])
        else:
            raise ValueError('Argument of mode should be train or test')
    
    def __len__(self):
        return len(self.x)
    
    def __getitem__(self, idx):
        return self.x[idx], self.y[idx]
#The client creates and save the dataset into .pt files (

train_dataset = ECG(mode='train')
test_dataset = ECG(mode='test')
torch.save(train_dataset, "train_dataset.pt")
torch.save(test_dataset, "test_dataset.pt")
#Code to send a string path to a dataset if using duet (Image by Author
#sy.lib.python.String(string_path).send(duet, pointable=True, tags=["data"])
#The server creates the remote dataset and remote data loader (Image by Author)
train_rds = RemoteDataset(path='train_dataset.pt', data_type="torch_tensor")
train_rdl = RemoteDataLoader(remote_dataset=train_rds, batch_size=32)
train_rdl_ptr = train_rdl.send(client)

我安装了所有需要的软件包版本,即,torch 1.8.1+cu102 和 syft 0.5.0

但我得到这个错误 torch version: 1.8.1+cu102 syft version: 0.5.0 project_path: C:\Users\a\SL Traceback (last last 最近调用): File "a.py", line 59, in train_rds = RemoteDataset(path='train_dataset.pt', data_type="torch_tensor") NameError: name 'RemoteDataset' is not defined

4

0 回答 0