Fixed Noise parameters

Hi everyone,

I know this question is fundamental for many of you, but I want to know the meaning of this 1, 1, in this torch. randn function while creating Gaussian noise distribution for generators.
input = 64
fixed_noise = torch.randn(64, nz, 1, 1, device=device)

Second: What is the meaning of (b_size**,** ) this comma after b_size parameter?

torch.full((b_size, ), real_label, dtype=torch.float, device=device)

  1. This is simply the size of the tensor you are creating. In your case you’ll get a Gaussian distributed (64, 100, 1, 1) tensor.
  2. This is again the size you are creating. In this case (as torch convention) the batch size is the first dim, and in torch.full you are creating a tensor of size batch_size filled with the required value.
    Since both this methods can receive any size tensor to create (python *args), you can pass the size of each dim separated by commas.

What is the meaning of 1, 1 is still unclear to me? Can you elaborate it more?

You can think of it as dummy dimensions. For example take a 2 matrices of shape h,w. Each is of shape (h,w). You can think of it as a 3D matrix where one of the dimensions is of size 1, let’s say (1,h,w). Now you can for example to concatenate the two 2d matrices on the first dim to get a (2,h,w) 3D matrix