Closed bollossom closed 1 year ago
File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py\h5f.pyx", line 106, in h5py.h5f.open OSError: Unable to open file (file signature not found) 下面这段代码出错(wrong) class Dataset(udata.Dataset): def init(self, train=True): super(Dataset, self).init() self.train = train if self.train: h5f = h5py.File('train.h5', 'r') # h5f = h5py.File('C:/pytorch/DnCNN-PyTorch-master/train.py', 'r') else: h5f = h5py.File('val.h5', 'r') self.keys = list(h5f.keys()) random.shuffle(self.keys) h5f.close() def len(self): return len(self.keys) def getitem(self, index): if self.train: h5f = h5py.File('train.h5', 'r') else: h5f = h5py.File('val.h5', 'r') key = self.keys[index] data = np.array(h5f[key]) h5f.close() return torch.Tensor(data)
你看他写的文档,运行train的时候要输入命令行参数
File "h5py_objects.pyx", line 54, in h5py._objects.with_phil.wrapper File "h5py_objects.pyx", line 55, in h5py._objects.with_phil.wrapper File "h5py\h5f.pyx", line 106, in h5py.h5f.open OSError: Unable to open file (file signature not found) 下面这段代码出错(wrong) class Dataset(udata.Dataset): def init(self, train=True): super(Dataset, self).init() self.train = train if self.train: h5f = h5py.File('train.h5', 'r')
h5f = h5py.File('C:/pytorch/DnCNN-PyTorch-master/train.py', 'r')