Solved by iacob in post #20 
              
              
                As of 1.8, PyTorch now has LazyLinear which infers the input dimension: 

A torch.nn.Linear module where in_features is inferred.