You could either manually calculate the activation shape, print it in the forward and use this printed shape as the input feature dimension for the needed module, or use the nn.Lazy* modules which will set their feature dimensions based on an input.