Morning all,
I am hoping that someone will be able to help me as I am at the end of my tether…
I am trying to write the autoencoder for  my network. having hit a problem i started experiementing with a know working decoder (shown below):
class Decoder(nn.Module):
def __init__(self, z_dim):
    super(Decoder, self).__init__()
    self.fc1 = nn.Linear(z_dim, 672)
    self.conv1 = nn.ConvTranspose1d(32, 32, 8, 2, padding=3)
    self.conv2 = nn.ConvTranspose1d(32, 32, 8, 2, padding=3)
    self.conv3 = nn.ConvTranspose1d(32, 16, 8, 2, padding=3)
    self.conv4 = nn.ConvTranspose1d(16, 16, 8, 2, padding=3)
    self.conv5 = nn.ConvTranspose1d(16, 1, 7, 1, padding=3)
    self.bn1 = nn.BatchNorm1d(32)
    self.bn2 = nn.BatchNorm1d(32)
    self.bn3 = nn.BatchNorm1d(16)
    self.bn4 = nn.BatchNorm1d(16)
    self.relu = nn.ReLU()


def forward(self, z):
    z = self.relu(self.fc1(z))
    print(z)
    print(z.shape)
   #z = F.dropout(z, 0.3)
    z = z.view(-1, 32, 21)
    z = self.relu(self.conv1(z))
    z = self.bn1(z)
    #z = F.dropout(z, 0.3)
    z = self.relu(self.conv2(z))
    z = self.bn2(z)
    #z = F.dropout(z, 0.3)
    z = self.relu(self.conv3(z))
    z = self.bn3(z)
    #z = F.dropout(z, 0.3)
    z = self.relu(self.conv4(z))
    z = self.bn4(z)
    #z = F.dropout(z, 0.3)
    z = self.conv5(z)
    recon = torch.sigmoid(z)
    return recon

summary(vae.decoder, (1, 2))
this gives the following results:
**tensor([[[0.0000, 0.3415, 0.6484,  ..., 0.2840, 0.0000, 0.3873]],**

**        [[0.0000, 0.4126, 0.6034,  ..., 0.2224, 0.0000, 0.3813]]],**
**       device='cuda:0', grad_fn=<ReluBackward0>)**
**torch.Size([2, 1, 672])**
**----------------------------------------------------------------**
**        Layer (type)               Output Shape         Param #**
**================================================================**
**            Linear-1               [-1, 1, 672]           2,016**
**              ReLU-2               [-1, 1, 672]               0**
**   ConvTranspose1d-3               [-1, 32, 42]           8,224**
**              ReLU-4               [-1, 32, 42]               0**
**       BatchNorm1d-5               [-1, 32, 42]              64**
**   ConvTranspose1d-6               [-1, 32, 84]           8,224**
**              ReLU-7               [-1, 32, 84]               0**
**       BatchNorm1d-8               [-1, 32, 84]              64**
**   ConvTranspose1d-9              [-1, 16, 168]           4,112**
**             ReLU-10              [-1, 16, 168]               0**
**      BatchNorm1d-11              [-1, 16, 168]              32**
**  ConvTranspose1d-12              [-1, 16, 336]           2,064**
**             ReLU-13              [-1, 16, 336]               0**
**      BatchNorm1d-14              [-1, 16, 336]              32**
**  ConvTranspose1d-15               [-1, 1, 336]             113**
**================================================================**
**Total params: 24,945**
**Trainable params: 24,945**
**Non-trainable params: 0**
**----------------------------------------------------------------**
**Input size (MB): 0.00**
**Forward/backward pass size (MB): 0.29**
**Params size (MB): 0.10**
**Estimated Total Size (MB): 0.38**
**----------------------------------------------------------------**
**which is expected.**

however changing the decoder to be included in a nn.sequential module the summary no longer works (see below).
class Decoder(nn.Module):
    def __init__(self, z_dim):
        super(Decoder, self).__init__()
        self.decode = nn.Sequential(OrderedDict([
            ('fc1',nn.Linear(z_dim, 672)),
            ('conv1',nn.ConvTranspose1d(32, 32, 8, 2, padding=3)),
            ('conv2',nn.ConvTranspose1d(32, 32, 8, 2, padding=3)),
            ('conv3',nn.ConvTranspose1d(32, 16, 8, 2, padding=3)),
            ('conv4',nn.ConvTranspose1d(16, 16, 8, 2, padding=3)),
            ('conv5',nn.ConvTranspose1d(16, 1, 7, 1, padding=3)),
            ('bn1',nn.BatchNorm1d(32)),
            ('bn2',nn.BatchNorm1d(32)),
            ('bn3',nn.BatchNorm1d(16)),
            ('bn4',nn.BatchNorm1d(16)),
            ('relu',nn.ReLU())
        ]))
        
        
    def forward(self, z):
        z = self.decode.relu(self.decode.fc1(z))
        print(z)
        print(z.shape)
        z = z.view(-1, 32, 31)
        z = self.decode(z)
        #z = self.relu(self.fc1(z))
        #z = F.dropout(z, 0.3)
        recon = torch.sigmoid(z)
        return recon
summary(vae.decoder, (1, 2))

This gives the following error:
tensor([[[0.6222, 0.0000, 0.0000,  ..., 0.0180, 0.3997, 0.3615]],

        [[0.7606, 0.0000, 0.0000,  ..., 0.0000, 0.2021, 0.2654]]],
       device='cuda:0', grad_fn=<ReluBackward0>)
torch.Size([2, 1, 672])
Traceback (most recent call last):

  File "G:/decoder-test.py", line 30, in forward
    z = z.view(-1, 32, 31)

RuntimeError: shape '[-1, 32, 31]' is invalid for input of size 1344

I know I have done something silly, but I cannot for the life of me see what (removing the         z = self.decode.relu(self.decode.fc1(z)) line just changes the size from 1344 to 4)…
I’m hopng that someone can point me in the correct direction…
Chaslie