Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Label Tensor slicing #135

Closed
dario-coscia opened this issue Jun 23, 2023 · 2 comments
Closed

Label Tensor slicing #135

dario-coscia opened this issue Jun 23, 2023 · 2 comments
Assignees
Labels
bug Something isn't working high priority Higher priority

Comments

@dario-coscia
Copy link
Collaborator

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.

@dario-coscia dario-coscia added the bug Something isn't working label Jun 23, 2023
@dario-coscia
Copy link
Collaborator Author

I tried for a while, but can't figure it out how to do it in a nice way. @ndem0 can I leave it to you? Thanks 😄

@dario-coscia dario-coscia removed their assignment Jun 28, 2023
@dario-coscia dario-coscia added high priority Higher priority and removed high priority Higher priority labels Jun 30, 2023
@ndem0 ndem0 added the high priority Higher priority label Jul 19, 2023
@dario-coscia
Copy link
Collaborator Author

Solved in #167 , closing issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working high priority Higher priority
Projects
None yet
Development

No branches or pull requests

2 participants