Average pooling problem

i want to replace my fully connected layers with average pooling or adaptive pooling layers

class ConvNet(nn.Module):
def init(self):
super(ConvNet, self).init()
self.layer1 = nn.Sequential(
nn.Conv1d(1, 32, kernel_size=3, stride=1 , padding=1),
nn.MaxPool1d(kernel_size=2, stride=2,))
self.layer2 = nn.Sequential(
nn.Conv1d(32,64, kernel_size=3, stride=1, padding=1),
nn.MaxPool1d(kernel_size=2, stride=2 ))
self.drop_out = nn.Dropout()
self.fc1 = nn.Linear(64*25, 1000)
self.drop_out = nn.Dropout()
self.fc2 = nn.Linear(1000, 2)

this step is how the data flow through these layers in forward pass

def forward(self, x):
    out = self.layer1(x)
    out = self.layer2(out)
    #out = self.layer3(out)
    out = out.reshape(-1, 64*25)
    out = self.drop_out(out)  
    out = self.fc1(out)
    out = self.drop_out(out)
    out = self.fc2(out)
    return out

I’m not sure, if I understand the question correctly, but you could just replace the linear layers assigned to self.fcX with your desired layers.
Since the expected input shape would be different, you might need to remove the .reshape operation.