मैं एक समस्या से मुलाकात की!
हाल ही में मैं एक समस्या है मैं/ओ के मुद्दे. लक्ष्य और इनपुट डेटा संग्रहित कर रहे हैं के साथ h5py फ़ाइलें. प्रत्येक लक्ष्य फ़ाइल है 2.6 GB जबकि प्रत्येक इनपुट फ़ाइल 10.2 GB. मैं 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-3 h5py फ़ाइलों को इस्तेमाल कर रहे हैं, मैं/हे गति सामान्य है और सब कुछ ठीक हो जाता है. हालांकि, जब 5 फाइलें इस्तेमाल कर रहे हैं, प्रशिक्षण की गति धीरे-धीरे कम (5 पुनरावृत्तियों/एस के लिए 1 पुनरावृत्तियों/एस). मैं बदल num_worker और समस्या अभी भी मौजूद है ।
सकता है किसी को मुझे एक समाधान दे? चाहिए मैं मर्ज कई h5py फ़ाइलों को एक बड़ा एक में? या अन्य तरीकों? अग्रिम में धन्यवाद!