Skip to content

Label Tensor slicing #135

Closed
Closed
@dario-coscia

Description

@dario-coscia

Describe the bug
Label Tensor when extracting only one column doesn't work.

To Reproduce

>>> x = torch.rand((10,2))
>>> labels = ['x', 'y']
>>> l_x = LabelTensor(x, labels)
>>> l_x
LabelTensor([[0.2713, 0.7692],
             [0.4961, 0.9652],
             [0.4201, 0.5002],
             [0.6814, 0.6618],
             [0.0545, 0.9571],
             [0.6296, 0.1529],
             [0.9426, 0.7315],
             [0.5458, 0.0875],
             [0.9378, 0.7342],
             [0.2751, 0.8039]])
>>> l_x[:, 0]
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/dariocoscia/Desktop/PINA/pina/label_tensor.py", line 201, in __getitem__
    selected_lt.labels = self.labels
  File "/Users/dariocoscia/Desktop/PINA/pina/label_tensor.py", line 85, in labels
    raise ValueError(
ValueError: the tensor has not the same number of columns of the passed labels.

Expected behavior

LabelTensor([[0.2713],
             [0.4961],
             [0.4201],
             [0.6814],
             [0.0545],
             [0.6296],
             [0.9426],
             [0.5458],
             [0.9378],
             [0.2751]])

with ['x'] as labels.

Metadata

Metadata

Assignees

Labels

bugSomething isn't workinghigh priorityHigher priority

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions