File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -21,10 +21,25 @@ by providing these two tensors, as well as the size of the sparse tensor
2121 >>> i = torch.LongTensor([[0 , 1 ], [2 , 0 ]])
2222 >>> v = torch.FloatTensor([3 , 4 ])
2323 >>> torch.sparse.FloatTensor(i, v, torch.Size([2 ,3 ])).to_dense()
24- 0 0 3
25- 4 0 0
24+
25+ 0 0 3
26+ 4 0 0
2627 [torch.FloatTensor of size 2x2]
2728
29+ You can also construct hybrid sparse tensors, where only the first n
30+ dimensions are sparse, and the rest of the dimensions are dense.
31+
32+ >>> i = torch.LongTensor([[2 , 4 ]])
33+ >>> v = torch.FloatTensor([[1 , 3 ], [5 , 7 ]])
34+ >>> torch.sparse.FloatTensor(i, v).to_dense()
35+
36+ 0 0
37+ 0 0
38+ 1 3
39+ 0 0
40+ 5 7
41+ [torch.FloatTensor of size 5x2]
42+
2843An empty sparse tensor can be constructed by specifying its size:
2944
3045 >>> torch.sparse.FloatTensor(2 , 3 )
You can’t perform that action at this time.
0 commit comments