Skip to content

Instantly share code, notes, and snippets.

@wanchaol
Last active August 24, 2018 07:54
Show Gist options
  • Save wanchaol/e45386221e1226791a34d5734856b7a3 to your computer and use it in GitHub Desktop.
Save wanchaol/e45386221e1226791a34d5734856b7a3 to your computer and use it in GitHub Desktop.
input = torch.randn(2,2)
part = torch.tensor([[1, 2]])
ind0 = torch.arange(0,1)
ind1 = torch.arange(0,2)
input = torch.index_put(input, (ind0, ind1), part)
---------------------------------------------------------------------------
RuntimeError Traceback (most recent call last)
<ipython-input-39-8e225bbb2c1f> in <module>()
6 ind1 = torch.arange(0,2)
7
----> 8 input = torch.index_put(input, (ind0, ind1), part)
RuntimeError: expand(torch.LongTensor{[1, 2]}, size=[2]): the number of sizes provided (1) must be greater or equal to the number of dimensions in the tensor (2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment