You should keep everything the same type in your neural net, from input to output, and also the weights. You could use torch.set_default_tensor_type('torch.FloatTensor') to set a default tensor type. If you want to train with GPU, you should make sure everything is torch.cuda.FloatTensor type.