# Unsqueeze noise

Hi,

`````` def unsqueeze_noise(self, noise):
'''
Function for completing a forward pass of the generator: Given a noise tensor,
returns a copy of that noise with width and height = 1 and channels = z_dim.
Parameters:
noise: a noise tensor with dimensions (n_samples, z_dim)
'''
return noise.view(len(noise), self.z_dim, 1, 1)

def forward(self, noise):
'''
Function for completing a forward pass of the generator: Given a noise tensor,
returns generated images.
Parameters:
noise: a noise tensor with dimensions (n_samples, z_dim)
'''
x = self.unsqueeze_noise(noise)
return self.gen(x)
``````

Can someone explain to me why is it noise.view(len(noise), self.z_dim, 1, 1)? What is happening here?

It returns a tensor view (a copy) reshaping the base tensor to (n_samples, self.z_dim, 1,1)

Why width and height= 1? @ricardo_freire

Hey @A_MR,
This is because, for every image, we take a 1-D tensor as the noise vector. You may refer to the lecture videos if you are unclear on this. However, for the purpose of feeding it into the layers of the generator, we need to reshape it. But if you think about it, the vector is the same, we have just added new dimensions.

For instance, assume n_samples = 100 and z_dim = 64, so, originally, the shape of the noise vector is (100, 64). Now, if we pass this vector through unsqueeze_noise, its shape will be (100, 64, 1, 1). However, the vector still contains the same elements.