The softmax method cannot be applied to LongTensors, as it would round them (and thus wouldn’t really make sense), so you should transform the incoming tensor to a FloatTensor via tensor = tensor.float().