Skip to content

Instantly share code, notes, and snippets.

@berlinbrown
Created June 8, 2024 10:38
Show Gist options
  • Save berlinbrown/0a27f0d9e1eeef3ef87386202d824ae9 to your computer and use it in GitHub Desktop.
Save berlinbrown/0a27f0d9e1eeef3ef87386202d824ae9 to your computer and use it in GitHub Desktop.
Example PyTorch
# Pytorch examples
import torch
import numpy as np
import time
randint = torch.randint(-100, 100, (6, ))
randint
print(randint)
tensor = torch.tensor([
[0.2, 0.2],
[1.2, 1.1],
[1.4, 1.5]
])
print(tensor)
device = 'cuda' if torch.cuda.is_available() else 'cpu'
print(device)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment