-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Inconsistant results between numpy.median() and torch.median() #1837
Comments
By the way, it seems that PyTorch's tensor in cuda does not have a median implemenation yet. I got this error message when trying to call it:
or
Maybe it should be a separate issue, but I think I should mention it here since it is also related to median funciton. |
wrt current behavior, it is intended and we will not be fixing it. wrt |
@lijunzh for some background on the decision to implement |
HI! I've learned how to emulate np.median with torch:
|
@stiv-yakovenko Thanks for the suggestion.
This line can be simplified as |
Hi, I know this issue is closed already, but I wonder why PyTorch has to implement median in such a inconsistent way with respect to other standard numerical libraries? I just got hit by this weird behavior and it took me a while to figure out what is going on. I understand that there are some good reasons for this design decision, but I just wonder what they are as the documentation seems not to discuss this issue. |
It should be stated explicitly in the documentation that torch and numpy median behave differently. |
Numpy seems to give the correct median of even number of elements (which is the mean of the center two elements) as defined in Wikipedia while torch gives one of the center elements that are closer to their mean (I guessed from the results I see). I am not sure if this is intended behavior or we need to fix this bug? As least, I think we should have a function that does the standard median for comparision with numpy or any other math programs, such as MATLAB.
The text was updated successfully, but these errors were encountered: