Skip to content

Instantly share code, notes, and snippets.

@travishsu
Last active December 27, 2018 00:17
Show Gist options
  • Save travishsu/5e575f9d95fa0199dff4d5f2b21d71ce to your computer and use it in GitHub Desktop.
Save travishsu/5e575f9d95fa0199dff4d5f2b21d71ce to your computer and use it in GitHub Desktop.
class YourDataset(torch.utils.data.Dataset):
def __init__(self, ...):
...
def __len__(self):
...
return num_all_examples
def __getitem__(self, idx):
...
return one_image, one_caption
dataset = YourDataset(...)
loader = torch.utils.data.DataLoader(dataset, ...)
for batch_images, batch_captions in loader:
# Train your network
....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment