waleedka / hiddenlayer

Neural network graphs and training metrics for PyTorch, Tensorflow, and Keras.
MIT License
1.79k stars 266 forks source link

Drawing error #12

Closed Kevinoop closed 5 years ago

Kevinoop commented 5 years ago

Why did I use your code to draw the picture in a mess? I don't know where it is wrong because I just copy your code on github.  mess

Kevinoop commented 5 years ago

waleedka commented 5 years ago

Can you share which code you used here? Based on the images it looks like the step counter is going to 170 and then going back and starting over, but can't be sure without seeing the code.

waleedka commented 5 years ago

Note that if you use epochs in your loop (i.e. loop over epochs and in it a loop over batches) then pass the step value as a tuple. For example, hl.log( (epoch, batch), ....).

Kevinoop commented 5 years ago

I only copied your code on github. Image of error

waleedka commented 5 years ago

The code looks good, and I tested it again to be sure and it's working correctly. I'm really puzzled by the drawing that you got. Did you change anything in the library itself?

Kevinoop commented 5 years ago

I didn't change anything in the library . I'm really strange, too. But I find that it will be nice if I change figure in the following .

Image of 1

waleedka commented 5 years ago

Interesting! And, another observation: in your first graph, the x-axis shows 10, 100, 110, ...etc. There is no 20, 30, 40. It's as if the values are being sorted like strings rather than integers. Do you have any global setting that might affect the x-axis of matplotlib?

Kevinoop commented 5 years ago

I check carefully and I do not set any global Settings. I'm also surprised that the x-coordinate is normal at first when drawing the picture at the beginning (10,20,...,70), and then it gets messy afterwards ( jump to 100,110,...)

Kevinoop commented 5 years ago

And I find a interesting thing- the code in the following if step % num ==0: when the variable num>=100, the picture will be nice and when num<100, the picture will be in mess. I like your resource very much and hope my problem will be solved, meanwhile, thank you for taking the time to answer my questions.

Kevinoop commented 5 years ago

In the process of drawing, the X-axis gets messy.  2

waleedka commented 5 years ago

Yes, your last comments confirm my suspicion that the x-axis is being sorted as a string rather than integer.

For example, 10, 20, 30, 40, 50, 60, 70, 80, 90. These will be sorted corrected both as string and integer.

However, once you add 100, it becomes 10, 100, 20, 30, 40, ...etc. Because 10 and 100 both start with "1", so they get sorted before 20, which starts with "2". Then you add 110, and the order becomes 10, 100, 110, 20, ....etc.

So we know the x-axis is being treated like a string. Now we need to know why. There are two possibilities:

  1. Some code is changing the step from integer to string. 2.Or, some global setting in matplotlib that causes the x-axis to be treated as a string.
Vvfshadow commented 5 years ago

Why can’t I get a dynamic picture in the same code? .... I only can get the saved .png images...

waleedka commented 5 years ago

@Kevinoop I'm going to close this issue because it's been inactive for a while, and it seems that it's specific to your setup, as far as I can tell. If you discover anything new that might explain the issue, please do post it here for the benefit of others.

MartSlaaf commented 5 years ago

For the searchers: It's highly likely, that you have matplotlib < 2.2.0 which produces a bug with axis sorting.

@waleedka it could be useful to add matplotlib >= 2.2.0 as pre-requisite for your library. And BTW, cool library, thanks!