How to index a two-dimension tensor with two single-dimension tensors
I want to index a two-dimension tensor like I do in numpy. <SCODE>TypeError: indexing a tensor with an object of type LongTensor. The only supported types are integers, slices, numpy scalars and torch.LongTensor or torch.ByteTensor as the only argument.
<ECODE> How do I index a two-dimension tensor using other two tensors?
Coldmooon
a[b, :][:, b] We plan to tackle this soon.
smth
Thanks for your reply. But this still gives the same error: <SCODE>>>> a[b,:][:,b]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: indexing a tensor with an object of type LongTensor. The only supported types are integers, slices, numpy scalars and torch.LongTensor or torch.ByteTensor as the only argument.
<ECODE> My pytorch vision is: <SCODE>$ conda list | grep torch  
pytorch                   0.1.10               py35_1cu80  [cuda80]  soumith
torchvision               0.1.6                   py35_19    soumith
<ECODE>
Coldmooon
b64406620
YankuHorn
x[b].transpose(1, 0)[b].transpose(1, 0) should do the trick. Which seems self-contradictory
dblythe
Can also try adding something like: <SCODE>_oldgetitem = torch.FloatTensor.__getitem__


def _getitem(self, slice_):
    if type(slice_) is tuple and torch.LongTensor in [type(x) for x in slice_]:
        i = [j for j, ix in enumerate(slice_)
             if type(ix) == torch.LongTensor][0]
        return self.transpose(0, i)[slice_[i]].transpose(i, 0)
    else:
        return _oldgetitem(self, slice_ )


torch.FloatTensor.__getitem__ = _getitem
<ECODE>
dblythe