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 update #188

Merged
merged 4 commits into from
Nov 2, 2023
Merged

Label Tensor update #188

merged 4 commits into from
Nov 2, 2023

Conversation

dario-coscia
Copy link
Collaborator

Updating LabelTensor class. Now passing to cuda/cpu and changing dtype is supported in LabelTensor. Additionally, we added the possibility to slice the tensor as:


labels = ['a', 'b']
data = torch.rand((10, 2))
tensor = LabelTensor(data, labels)
tensor_view = tensor['a']            # same as tensor.extract('a')

@dario-coscia
Copy link
Collaborator Author

@ndem0 I noticed from dir(torch.Tensor) that many implemented methods for torch lose the label. For example, let x a label tensor, then:

y1 = x.clamp(0,1)
y2 = torch.clamp(x, 0, 1)

both y1 and y2 will lose the label. Is this something that we can fix? For the first case (y1 = x.clamp(0,1)) we could think to override all the methods found in dir(torch.Tensor), for the second case I have no idea...

@dario-coscia dario-coscia requested a review from ndem0 October 18, 2023 17:04
@dario-coscia
Copy link
Collaborator Author

@ndem0 can we merge it?

@dario-coscia dario-coscia added pr-to-review Label for PR that are ready to been reviewed good first issue Good for newcomers v0.2 implementation in v0.2 labels Oct 30, 2023
@ndem0
Copy link
Member

ndem0 commented Oct 30, 2023

@ndem0 can we merge it?

The test using [] operator is still not present. What should be the result for

label_tensor['a', 'b']

@ndem0 ndem0 added pr-to-fix Label for PR that needs modification and removed pr-to-review Label for PR that are ready to been reviewed good first issue Good for newcomers labels Oct 31, 2023
@dario-coscia
Copy link
Collaborator Author

@ndem0 can we merge it?

The test using [] operator is still not present. What should be the result for

label_tensor['a', 'b']

Added the test!

@dario-coscia dario-coscia added pr-to-review Label for PR that are ready to been reviewed and removed pr-to-fix Label for PR that needs modification labels Oct 31, 2023
@ndem0 ndem0 merged commit f9441c0 into v0.1 Nov 2, 2023
13 of 14 checks passed
@ndem0 ndem0 deleted the lab-tensor branch November 7, 2023 10:38
ndem0 pushed a commit that referenced this pull request Nov 17, 2023
* Update test_label_tensor.py
* adding test

---------

Co-authored-by: Dario Coscia <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr-to-review Label for PR that are ready to been reviewed v0.2 implementation in v0.2
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants