Open vmtmxmf5 opened 3 years ago
class BasicDataset(data.Dataset): def __init__(self, x_tensor, y_tensor): super(BasicDataset, self).__init__() self.x = x_tensor self.y = y_tensor def __getitem__(self, index): return self.x[index], self.y[index] def __len__(self): return len(self.x)
getitem은 sample(batch_size=1)마다 메모리에 올리기 위해 사용한다 데이터의 크기가 클 경우, 한 번에 모든 데이터를 메모리에 올릴 수 없으므로 이렇게 map-style dataset을 사용하는 것이다
len는 batch_size로 sample수가 딱 떨어지지 않을 때를 대처하기 위해서 사용한다
https://hulk89.github.io/pytorch/2019/09/30/pytorch_dataset/ https://sanghyu.tistory.com/90
getitem은 sample(batch_size=1)마다 메모리에 올리기 위해 사용한다
데이터의 크기가 클 경우, 한 번에 모든 데이터를 메모리에 올릴 수 없으므로 이렇게
map-style dataset을 사용하는 것이다
len는 batch_size로 sample수가 딱 떨어지지 않을 때를 대처하기 위해서 사용한다
https://hulk89.github.io/pytorch/2019/09/30/pytorch_dataset/ https://sanghyu.tistory.com/90