What do you want to save?
Add Code snippet
New code examples
-
Python 2021-09-27 10:49:02
pytorch check gpu
In [1]: import torch In [2]: torch.cuda.current_device() Out[2]: 0 In [3]: torch.cuda.device(0) Out[3]: <torch.cuda.device at 0x7efce0b03be0> In [4]: torch.cuda.device_count() Out[4]: 1 In [5]: torch.cuda.get_device_name(0) Out[5]: 'GeForce GTX ... Add solution -
Python 2021-09-25 05:52:02
pytorch lightning init not on cuda
# tensor created in __init__ wont be added to cuda # use self.register_buffer to register variables class LitModel(LightningModule): def __init__(self): ... self.register_buffer("sigma", torch.eye(3)) # you can now... Add solution -
Other 2021-09-20 06:26:07
Creating csv file
import pandas as pdimport osimport torchdevice = ("cuda" if torch.cuda.is_available() else "cpu")train_df = pd.DataFrame(columns=["img_name","label"])train_df["img_name"] = os.listdir("train/")fo... Add solution -
Python 2021-09-19 12:17:02
recurrent neural network pytorch
import torch from torch import nn # check documentation in the source link for further information rnn = nn.RNN(10, 20, 2) # initialize vectors at t=0 x = torch.randn(5, 3, 10) h0 = torch.randn(2, 3, 20) output, hn = rnn(x, h0) Add solution
Best helpers
Bob R Bogle
+5
Eric Vought
+5
James Song
+5
Fishbean
+5
Mai Rose
+5
Cpurick
+5
Puneet Goel
+5
Bunch
+5
Rainbow
+5
Gruppetto
+5
Katboodle
+5
Vidhi Patel
+5
Buttercup
+5
Bin Nguyễn
+5