# Create the generator netG = [Generator](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module "torch.nn.Module")(ngpu).to([device](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.device "torch.device")) # Handle multi-GPU if desired if ([device](https://docs.pytorch.org/docs/stable/tensor_attributes.html#torch.device "torch.device").type == 'cuda') and (ngpu > 1): netG = [nn.DataParallel](https://docs.pytorch.org/docs/stable/generated/torch.nn.DataParallel.html#torch.nn.DataParallel "torch.nn.DataParallel")(netG, list(range(ngpu))) # Apply the ``weights_init`` function to randomly initialize all weights # to ``mean=0``, ``stdev=0.02``. [netG.apply](https://docs.pytorch.org/docs/stable/generated/torch.nn.Module.html#torch.nn.Module.apply "torch.nn.Module.apply")(weights_init) # Print the model print(netG)