Code conversion from python 2 to python 3
I'm setting up a new algorithm which combines an object detector(bounding box detector) which is in python 3 and a mask generator which is in python 2. The problem here is I have several python 2 files which is required for the mask generation algorithm. So I tried 2to3 to convert all my python 2 files to python 3. The script seemed like working but as it was a deep learning algorithm(for mask generation when bounding box coordinates are given as input) which needs some pytorch weights to be loaded, while testing the model in python 3 the program was throwing out error like


  "RuntimeError: Expected object of type torch.FloatTensor but found
  type torch.cuda.FloatTensor for argument #2 ‘weight’"


I have searched in PyTorch forums but none of the posts were useful to me. Is it because my mask generation code is trained in python 2 ?

Does that means while loading the weights and testing the model I should use python 2 not python 3 ? It would be great if someone can shed some light on this. As a work around I can still use the object detector code downgraded to python 2. But still I want to know why it was throwing the error. 

I just resolved the issue by re-installing the torch(0.4.0) and torchvision(0.2.1) for my conda environment. I had to downgrade the versions of both of them. Finally I was successful in converting my python 2.7 code to python 3. Thanks to 2to3 library. Actually this error was happening in the image normalize function of the PyTorch. That was an internal function which accepts the image array as tensors. 

tensor.sub_(mean[:, None, None]).div_(std[:, None, None]) 
RuntimeError: expected type torch.cuda.FloatTensor but got torch.FloatTensor

