Solved by bgenchel in post #4 
              
              
                The problem is that nn.Linear in general doesn’t take LongTensor, it only takes FloatTensor, because it’s internal weight matrix, ‘mat2’ here, is a FloatTensor. 
It would be helpful if this type of thing were caught at a higher level so that the error message was clear and helpful instead of allow…