Quetions about train DCGAN

In the pytorch demo, there is a DCGAN code

In this picture,

I don’t understand input.data.resize_ and label.data.resize_. Why not use input.resize_ and label.resize_.
Thanks for help!

I am not totally sure, because I am still learning PyTorch, so take my answer with a pinch of salt.

input and label types are Variable. They are not Tensors, instead they are objects that encapsulate the Tensors and all their history (the operations that they have done).

You neither can (you get a NameError if you try to do so) - nor want - to resize the Variable objects. What you want to do is to resize the Tensors within the variable and you can do that by using precisely the given code (data function).

@Ismail_Elezi correct. But we should change the example, it’s a better practice to recreate Variables from scratch.

Why is the input tensor resized in every iteration of the loop? Is there a computational overhead in doing this?