backprop.py 405 Bytes
Newer Older
rusty1s's avatar
rusty1s committed
1
2
3
4
5
6
7
8
9
10
11
12
import torch
from torch.autograd import Variable

size = torch.Size([2, 2])

index = torch.tensor([[0, 1], [1, 0]], dtype=torch.long).cuda()
value = torch.tensor([1, 1], dtype=torch.float).cuda()
A = torch.cuda.sparse.FloatTensor(index, value, size)

index = torch.tensor([[0, 1], [0, 1]], dtype=torch.long)
value = torch.tensor([1, 1], dtype=torch.float)
B = torch.sparse.FloatTensor(index, value, size)