Created
November 21, 2017 19:05
-
-
Save t-vi/b1e455fc93120548be83191f2bd6b45c to your computer and use it in GitHub Desktop.
add.at-like addition using sparse matrices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import torch | |
indices = torch.LongTensor([[1,1,1], | |
[2,1,1]]) # must be two dimensional with one row per dimension | |
values = torch.arange(1,4) | |
size = torch.Size((3,3)) | |
a = torch.sparse.FloatTensor(indices, values, size) | |
b = torch.eye(3) | |
b += a | |
print (b) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment