Hi,
I am trying to implement a GAN network using the documentation and the DCGAN tutorial provided. My discriminator looks like below
class Discriminator(torch.nn.Module):
def __init__(self, ngpu):
super().__init__()
self.ngpu = ngpu
self.discriminator = torch.nn.Sequential(
torch.nn.Conv2d(args["dim_Image"][2],
64,
3,
stride=1,
padding=0,
bias=False),
# channel size (64, 95, 95)
torch.nn.Tanh(),
torch.nn.Conv2d(64,
128,
5,
stride=2,
padding=1,
bias=False),
# channel size( 128, 47, 47)
torch.nn.Tanh(),
torch.nn.Conv2d(128,
256,
5,
stride=2,
padding=1,
bias=False),
# channel size(256, 23, 23)
torch.nn.Tanh(),
torch.nn.Conv2d(256,
512,
5,
stride=2,
padding=1,
bias=False),
# channel size (512, 11, 11)
torch.nn.Tanh(),
torch.nn.Conv2d(512,
1024,
5,
stride=2,
padding=1,
bias=False),
# channel size (1024, 5, 5)
torch.nn.Tanh(),
torch.nn.Conv2d(1024,
1024,
5,
stride=1,
padding=0,
bias=False),
# channel size(1024, 1, 1)
torch.nn.Tanh(),
torch.nn.Linear(args["batch_size"]*1024,
args["batch_size"],
bias=False),
torch.nn.Sigmoid())
def forward(self, input):
return self.discriminator(input)
This code is throwing an error and rightly so. However when I change the torch.nn.Linear() function to
torch.nn.Linear(1024, 1, bias=False),
it still throws error. I am not sure if I understand correctly the workings of the sequential module. In my opinion the above piece of code shouldn’t throw error for a single image. Shouldn’t it also be the case for the batch ?
If someone could please explain how the batches are processed and how to rectify my code, it would be hugely helpful.
Thanking you and warm regards,
Nirmal