를 만났습니다.
최근을 충족 문제의 I/O 문제입니다. 대상 및 데이터 입력과 함께 저장하 h5py 파일이 있습니다. 각각의 대상 파일은 2.6GB 는 각각의 입력 파일 10.2GB. 나는 5 개의 입력 데이터 및 5 대상 데이터 집합니다.
만든 사용자 정의 데이터 집합 기능을 위해 각 h5py 파일을 다음 사용 데이터입니다.ConcatDataset 클래스를 연결하는 모든 데이터 집합입니다. 사용자 정의 데이터 집합의 기능은 다음과 같습니다
class MydataSet(Dataset):
def __init__(self, indx=1, root_path='./xxx', tar_size=128, data_aug=True, train=True):
self.train = train
if self.train:
self.in_file = pth.join(root_path, 'train', 'train_noisy_%d.h5' % indx)
self.tar_file = pth.join(root_path, 'train', 'train_clean_%d.h5' % indx)
else:
self.in_file = pth.join(root_path, 'test', 'test_noisy.h5')
self.tar_file = pth.join(root_path, 'test', 'test_clean.h5')
self.h5f_n = h5py.File(self.in_file, 'r', driver='core')
self.h5f_c = h5py.File(self.tar_file, 'r')
self.keys_n = list(self.h5f_n.keys())
self.keys_c = list(self.h5f_c.keys())
# h5f_n.close()
# h5f_c.close()
self.tar_size = tar_size
self.data_aug = data_aug
def __len__(self):
return len(self.keys_n)
def __del__(self):
self.h5f_n.close()
self.h5f_c.close()
def __getitem__(self, index):
keyn = self.keys_n[index]
keyc = self.keys_c[index]
datan = np.array(self.h5f_n[keyn])
datac = np.array(self.h5f_c[keyc])
datan_tensor = torch.from_numpy(datan).unsqueeze(0)
datac_tensor = torch.from_numpy(datac)
if self.data_aug and np.random.randint(2, size=1)[0] == 1: # horizontal flip
datan_tensor = torch.flip(datan_tensor,dims=[2]) # c h w
datac_tensor = torch.flip(datac_tensor,dims=[2])
다음 사용 dataset_train = data.ConcatDataset([MydataSet(indx=index, train=True) for index in range(1, 6)])
에 대한 교육입니다. 경우는 2~3h5py 파일은 사용되는 I/O 속도가 정상적이고 모든 것이 바로 간다. 그러나,5 개의 파일을 사용하는 훈련 속도로 점차적으로 감소(5 회 반복/s1 반복/s). 나는 변경 num_worker 및 문제는 여전히 존재합니다.
할 수 있었 사람을 나에게 솔루션을 제공? 어야 나는 여 h5py 파일 더 큰 하나? 또는 다른 방법이 있나요? 사전에 감사합니다!