Skip to content

indexing bug on Variable #94

@soumith

Description

@soumith

RuntimeError: indexing a tensor with an object of type tuple. The only supported types are integers, slices and torch.ByteTensor.

from torch.autograd import Variable
b = Variable(torch.randn(10, 20))
b[:,:5]
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-9-039a3f3ae91a> in <module>()
----> 1 b[:,:5]

/Users/soumith/anaconda/lib/python2.7/site-packages/torch/autograd/variable.pyc in __getitem__(self, key)
     55         if isinstance(key, Variable) and isinstance(key.data, torch.ByteTensor):
     56             return MaskedSelect()(self, key)
---> 57         return Index(key)(self)
     58 
     59     # TODO: setitem

/Users/soumith/anaconda/lib/python2.7/site-packages/torch/autograd/function.pyc in __call__(self, *input)
     16 
     17     def __call__(self, *input):
---> 18         return self._do_forward(*input)
     19 
     20     def save_for_backward(self, *tensors):

/Users/soumith/anaconda/lib/python2.7/site-packages/torch/autograd/function.pyc in _do_forward(self, *input)
     48             self.previous_functions = [(arg.creator or arg, id(arg)) for arg in input]
     49 
---> 50         raw_output = self.forward(*unpacked_input)
     51         if not isinstance(raw_output, tuple):
     52             raw_output = (raw_output,)

/Users/soumith/anaconda/lib/python2.7/site-packages/torch/autograd/functions/tensor.pyc in forward(self, i)
     15     def forward(self, i):
     16         self.input_size = i.size()
---> 17         return i[self.index]
     18 
     19     def backward(self, grad_output):

RuntimeError: indexing a tensor with an object of type tuple. The only supported types are integers, slices and torch.ByteTensor

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions