Skip to content

Instantly share code, notes, and snippets.

@shwang
Created October 14, 2020 05:47
Show Gist options
  • Save shwang/53f8a522dfe052f177749dbf62abc4f2 to your computer and use it in GitHub Desktop.
Save shwang/53f8a522dfe052f177749dbf62abc4f2 to your computer and use it in GitHub Desktop.
import torch as th
import torch.utils.data as th_data
def main():
x = th.ones([30, 3, 3], requires_grad=True)
y = x * 2
dl = th_data.DataLoader(y)
batch = next(iter(dl))
print(f"batch: {batch}")
batch2 = th.as_tensor(batch)
print(f"batch2: {batch2}")
print(f"batch is batch2: {batch is batch2}")
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment