-
Notifications
You must be signed in to change notification settings - Fork 35
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
Can I sort by specific column? #34
Comments
Hi @zimonitrome, this is not possible with this library |
@teddykoker I made a version of soft_sort that sorts batches of 2D tensors by a given column. https://github.com/zimonitrome/AbstractionNet/blob/main/src/SoftSortByColumn.py Would any of this functionality be relevant for a pull request? |
Nice work! What would you think about having the current |
That could be a great way of doing it, but that would not extend the "softness" to the remaining columns. I remember trying that method previously and it seemed to restrict the gradients for that specific training script. Even now, the linked way of performing column sorting seems to produce nice gradients but only for multiple samples; In the repo I linked, a network seems to be able to backdrop through the column sort to order a set of rendered shapes for rendering, but this same information does not seem utilized when running an optimizer (without a NN) for a single sample. Maybe I should come up with a more simple toy problem to better test how useful gradients are in the two proposed methods. |
Thats a great point! Having a toy example would certainly be beneficial in determining the best way to proceed. |
@zimonitrome I was toying with your implementation to build a custom loss. But my model doesn't seem to learn (while it does with 'trivial' losses). Are you sure the gradient is correctly computed ? |
@lcrmorin Thanks for trying it out. I thought it was working pretty well but for my odd use-case it only seemed to work with mutli-batch training and not single sample training. I thought this mostly had to do with operations that occur after the column sorting but perhaps it could be that the implementation itself has some bug. When making it I thought it was pretty air tight and worked in the same way as the original torchsort. Please try to see if you can improve it in any way. If you have troubles, I could send some of my notes that better demonstrate what the code does. |
@zimonitrome
The value of the result is "(tensor([[0.]], device='cuda:0'), tensor([0.], device='cuda:0'))". |
Any updates on this?? |
I strongly support this feature. I have the use case where I obtain an arbitrary amount of input vectors, and I would like to learn an automatic sorting of these vectors. This could be achieved by predicting a value per vector, and differentiably sorting the vectors according to that singular value. |
Is there any way to sort a tensor by a given column?
For example, soring by first column:
The text was updated successfully, but these errors were encountered: