Skip to content

Instantly share code, notes, and snippets.

@foowaa
Created December 16, 2018 17:07
Show Gist options
  • Save foowaa/db7617f22103168cea1bac4fc531971e to your computer and use it in GitHub Desktop.
Save foowaa/db7617f22103168cea1bac4fc531971e to your computer and use it in GitHub Desktop.
import torch.utils.data as data
class MyDataset(data.Dataset):
'''
Dataset must define __getitem__ and __len__
'''
def __init__(self, others):
pass
def __getitem__(self, index):
"""
index位置的(x, y), x和y都是tensor
Returns one data pair (x and y).
"""
return x, y
def __len__(self):
# 0<= index < lens
return lens
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment