x = random_hot
x = x.unsqueeze(1)
x = torch.nn.Embedding(vocab_size,100)(x)
x = torch.nn.Flatten()(x)
print(x.shape)
x = x.unsqueeze(0)
for i in range(5):
x = torch.nn.Conv1d(x.shape[1], 50, 100, stride=1)(x)
x = torch.nn.ReLU()(x)
x = torch.nn.Conv1d(x.shape[1], 50, 100, stride=2)(x)
x = torch.nn.ReLU()(x)
x = torch.nn.Flatten()(x)
x = torch.nn.Linear(x.shape[1],512)(x)
x = torch.nn.ReLU()(x)
x = torch.nn.Linear(512,128)(x)
x = torch.nn.Linear(128,1)(x)
This sends my input through the network without errors. I put this in the forward() call of a new nn.Module object.  I left the init empty. When I tried using an optimizer, it gives an error saying model.parameters() are empty.
I thought I may need to put all my layers explicitly in the init part of the module. For instance
self.conv1 = nn.Conv1d( …)
self.conv2 = nn.Conv1d( …)
…
self.conv10 = nn.Conv1d( …)
Is this the case and if so, how would I encode the dynamic shape of x.shape[1] which my loop relies on? Is this even how I get model.parameters to be saved so I can use an optimizer?