-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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
Throw ValueError for wrong reduction in losses #6604
Comments
Looking at https://github.com/pytorch/vision/pull/6457/files, it looks like this is taken care of in the original PR already? Or were you referring to other losses @oke-aditya ? |
I think @oke-aditya refers to all the other losses. I believe that's a good idea but if the ticket is intended for a new contributor, it's worth listing explicitly all the places were the change needs to happen and a potential idiom we want to adopt. This will help people who are not familiar with our code-base to pick it up. |
Yeah I'm referring to all the other losses. I will add further details to help new contributors 😃 |
Well I hope I have edited the issue and explained it in bit more detail. I haven't given away the code of what needs to be done intentionally (as I believe some new contributor should try to figure out and interact with people while fixing) cc @datumbox |
@oke-aditya Looks great to me! Thanks for helping us attract more contributors :) |
I can work on this. Would you please assign me the task? |
@adityagandhamal Also btw how did you come to know about this issue? |
I recently started using PyTorch and was browsing about, looking for anything to contribute to, and fortunately, I came upon this! |
@adityagandhamal Welcome! I've assigned the ticket to you, looking forward to your PR! |
Yes. I've finished making the necessary changes to the code and am now working on the tests. Will send the PR soon. |
While running a test on Quite strange to have encountered such an error given the loss function exists in the module |
This sounds weird. It seems like if TorchVision is not properly installed. I would start by a fresh conda environment and follow this guide. Let me know if you continue facing problems. |
Yes, I've been following the same guide but nonetheless, I'll go for it again. And pardon me if this sounds naive but one has to clone the forked repo into their local machine but in the guide, why is it mentioned to clone the parent repo? |
Can you send detailed log of the same? Sorry I can't help much as I use linux only.
Yeah you need to clone the fork. The guide might be written to build from source and not to contribute. |
Okay, after spending some time on StackOverflow and rebooting the system, now it seems everything is good to go. @oke-aditya @datumbox |
Actually you are doing quite a difficult thing. Building on windows. Much harder. WSL2 can help you though to make it easier. Have you run
|
Also I believe we should have a step by step guide for windows @datumbox most of us don't probably use windows and it's a pain point for new developers to setup. For Linux it's very very straightforward and hardly takes an hour. |
Yes, I have. It ran without giving any error and returned |
Yes, I agree that developing on WSL is always a better option. On WSL as well, should the same steps be followed (according to the guide) as before? |
Yeah WSL you can just install Ubuntu and follow the steps mentioned for Linux. On WSL I believe you will need
Basically 4 is
|
WSL2 is great @oke-aditya! torchvision has successfully set up. No absurd errors so far. |
One of the nice things about good first issues is that it helps to understand what the difficulty a new contributor may face. It's quite ok and in fact expected that a new contributor will need help in getting started and setting up. So nothing wrong about seeking help. Keep going @adityagandhamal (btw our first name is the same 😃) |
@oke-aditya @datumbox |
As discussed in #6457
The current problem
We do not restrict the reduction mode in losses. There are only three cases possible, ["none", "mean", "sum"]. If the user passes something like "xyz" we are not throwing any error or warning.
The solution
If users aren't passing one of the valid cases and using a random string instead. It's better to throw a ValueError suggesting them to use one of the correct choice.
We had thought of Enum based solution, but to keep better consistency with Pytorch core as discussed, we are adopting the above solution.
Edits required
Need to edit losses. which are namely
ciou_loss, diou_loss, giou_loss, and focal_loss
Also need to edit the relevant tests in test_ops.py
Additional Context
I think it's good first issue and some new contributor can take this 😃
Feel free to ping the maintainers or me if you need help. 😄
The text was updated successfully, but these errors were encountered: