You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When I run the eval.py given trained model results in the following form: python2 ./eval.py --model_path ./save/model.pth --infos_path ./save/infos_st.pkl --cnn_model_path ./save/model-cnn.pth --image_folder ./data/images/val --num_images 10
I got the runtime error like the following:
Traceback (most recent call last):
File "./eval.py", line 121, in <module>
vars(opt))
File "/home/student51/lab2/code/eval_utils.py", line 158, in eval_split
alp_curr = alph[k,t,:].view(7,7).data.cpu().numpy()
File "/usr/local/lib/python2.7/dist-packages/torch/tensor.py", line 374, in data
raise RuntimeError('cannot call .data on a torch.Tensor: did you intend to use autograd.Variable?')
RuntimeError: cannot call .data on a torch.Tensor: did you intend to use autograd.Variable?
I then changed the code in eval_utils.py line 158 into alp_curr = alph[k,t,:].view(7,7).numpy()
Then the evaluation completed without any errors, output caption-image pairs in the vis folder (meta information in vis/vis.json & images in vis/images/) and attention images in the code folder, as well as the evaluation loss shown in stdout.
My question is: should we do such modification in eval_utils.py line 158? Or am I breaking something else without receiving explicit error messages?
In my case I need to change alph from GPU mode to CPU mode, so it needs to do .cpu().
Maybe your return type of alph is different from mine, so you need to modify the code.
Activity
connie980149 commentedon Nov 19, 2017
In my case I need to change alph from GPU mode to CPU mode, so it needs to do .cpu().
Maybe your return type of alph is different from mine, so you need to modify the code.