torch.zeros() gives tensors of type Float, but in this case it’s not what u want. So u should change it to Long type, like input_zero = torch.zeros(batch_size, 3, 5, 32).long().cuda() or input_zero = torch.zeros(batch_size, 3, 5, 32,dtype=torch.long,device=UR_GPU).