Loading weights doesn't generate the image

##checkpoints are loaded successfully and all keys match successfully

print("=> Loading checkpoint")

checkpoint = torch.load(’/content/High/generator_C.pth’, map_location=“cuda”)

gen.load_state_dict(checkpoint[‘state_dict’])

now feeding noise to the generator t get the desired image

alpha = 1.0

for i in range(10):

noise =torch.randn((1, Z_DIM, 1, 1))

img_size=128

num_steps = int(log2(img_size / 4))

img = gen(noise, alpha, steps=num_steps)

save_image(img*0.5+0.5, f"/content/img_{i}.png")

###but the output image is’
image

I assume you’ve saved some output images during your training (or the validation step in the training script) and are now comparing them to this new output in another script?
If so, did you make sure to use the same input data distribution (i.e. was the noise tensor also created via torch.randn before)?

yes noise tensor was created via torch.rand.
I am getting one more error while genenrating fake images:
ERROR:
Input type (torch.cuda.FloatTensor) and weight type (torch.FloatTensor) should be the same
what does this mean?
Is this the reason i am not getting fake images?

The error points towards a device mismatch and it seems you haven’t pushed the parameters of the model to the device, so you might want to add gen.to('cuda').

If this error was also raised before, the gen model shouldn’t have worked and I’m unsure where the initial output image is coming from.

So do I need to push gen.cuda() before training?

Based on the error message this would be my guess.
Did you try it and was it working?

Thanks solved .the input should be pushed to the cuda().before training