As the error message says, on this line Alpha.append(abssum/count), you perform a tensor operations between a FloatTensor and a LongTensor while both should be of the same type. I would guess abssum is a FloatTensor and count is a LongTensor? You need to convert the LongTensor into a FloatTensor with .float() or .type_as(the_other).