CuriousAI / mean-teacher

A state-of-the-art semi-supervised method for image recognition
https://arxiv.org/abs/1703.01780
Other
1.56k stars 331 forks source link

RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #2 'other' #20

Closed zhangxgu closed 5 years ago

zhangxgu commented 5 years ago

The results of running python main.py ...... are showed as following:

Traceback (most recent call last): File "main.py", line 424, in main(RunContext(file, 0)) File "main.py", line 104, in main train(train_loader, model, ema_model, optimizer, epoch, training_log) File "main.py", line 274, in train meters.update('top1', prec1[0], labeled_minibatch_size) File "/home/gzx/Meanteacher/mean-teacher/pytorch/mean_teacher/utils.py", line 53, in update self.meters[name].update(value, n) File "/home/gzx/Meanteacher/mean-teacher/pytorch/mean_teacher/utils.py", line 86, in update self.sum = self.sum +(val * n) RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.cuda.LongTensor for argument #2 'other'

Is this because I install pytorch by using conda? The pytorch version is 0.4.1

tarvaina commented 5 years ago

Hi.

Yes, I think it’s a Pytorch version issue. Please try 0.3.1 and let me know if it solves the problem.

Antti

zhangxgu commented 5 years ago

@tarvaina I have changed the pytorch version to 0.3.1 and it works, thanks!