Open MelonEater opened 4 years ago
I also saw this issue
same problem encountered when running python main.py
from
https://github.com/valerystrizh/pytorch-histogram-loss
but use your modified code, pytorch-histogram-loss runs sucessfully.
`if Y.ndim == 2 and Y.shape[1] == 1: Y = Y.reshape(Y.shape[0]) # I modify here X = X.reshape(X.shape[0])
if Y.ndim == 2 and X.ndim == 1: X = np.tile(X, (Y.shape[1], 1)).transpose()
assert X.shape == Y.shape, 'X and Y should be the same shape'`
Same issue. Inputs:
And return:
There is indeed a bug in visdom\__init__.py
. When Y
is two dimensional and the second dimension is 1 (when plotting multiple points of a single line) Y
and X
are reshaped for no reason and the run is eliminated when asserting X
and Y
are of the same shape.
The quickest fix is to eliminate the following code lines in the line
function:
if Y.ndim == 2 and Y.shape[1] == 1:
Y = Y.reshape(1, Y.shape[0])
X = X.reshape(X.shape[0])
On the other hand, add multiple lines to your plot and avoid this issue altogether.
Is it possible to submit a pull request to fix this?
Bug Description When I use visdom.line() to draw a pic, the code give me the information "X and Y should be the same shape". So I go to see the source code, to find where I get wrong with. After thinking and testing, I think there may exist a bug. The bug code is here:
So if I send the function line(X=x_input, Y=y_input), where x_input is an 'N' tensor or 'Nx1' tensor , and y_input is an 'Nx1' tensor, that is I just want to draw a line. When x_input and y_input go through following code,y_input will be an '1xN' tensor, and x_input will be an 'N' tensor.
Then they can go through following code, after this, X become an 'NxN' tensor, so it will cause assert above.
So I think the code should be:
Reproduction Steps
Expected behavior See bug description.
Screenshots