SourceChangeWarning
See original GitHub issueProblem:
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torchvision.models.resnet.Bottleneck’ has changed. yo
u can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to r
evert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.batchnorm.BatchNorm2d’ has changed.
you can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to
revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torchvision.models.resnet.Bottleneck’ has changed. yo
u can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to r
evert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.DecoderWithAttention’ has changed. you can ret
rieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the
changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.Attention’ has changed. you can retrieve the o
riginal source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.linear.Linear’ has changed. you can
retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert
the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.sparse.Embedding’ has changed. you c
an retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to reve
rt the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.rnn.LSTMCell’ has changed. you can r
etrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert t
he changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File “caption.py”, line 222, in <module>
seq, alphas = caption_image_beam_search(encoder, decoder, args.img, word_map, args.beam_size)
File “caption.py”, line 45, in caption_image_beam_search
image = transform(img) # (3, 256, 256)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 60, in call
img = t(img)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 163, in call
return F.normalize(tensor, self.mean, self.std, self.inplace)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\functional.py”, line 208, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #4 ‘other’
(empty) E:\Program Files\a-PyTorch-Tutorial-to-Image-Captioning>
(empty) E:\Program Files\a-PyTorch-Tutorial-to-Image-Captioning>python caption.py --img=e:/paper.jpg --model=fake/BEST_checkpoint_coco_5_cap_per_img_5_min_
word_freq.pth.tar --word_map=fake/WORDMAP_coco_5_cap_per_img_5_min_word_freq.json --beam_size=5
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.Encoder’ has changed. you can retrieve the ori
ginal source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.conv.Conv2d’ has changed. you can re
trieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert th
e changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.batchnorm.BatchNorm2d’ has changed.
you can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to
revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torchvision.models.resnet.Bottleneck’ has changed. yo
u can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to r
evert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.DecoderWithAttention’ has changed. you can ret
rieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the
changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.Attention’ has changed. you can retrieve the o
riginal source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.linear.Linear’ has changed. you can
retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert
the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.sparse.Embedding’ has changed. you c
an retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to reve
rt the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.rnn.LSTMCell’ has changed. you can r
etrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert t
he changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File “caption.py”, line 222, in <module>
seq,alphas = caption_image_beam_search(encoder, decoder, args.img, word_map, args.beam_size)
File “caption.py”, line 45, in caption_image_beam_search
image = transform(img) # (3, 256, 256)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 60, in call
img = t(img)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 163, in call
return F.normalize(tensor, self.mean, self.std, self.inplace)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\functional.py”, line 208, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #4 ‘other’
(empty) E:\Program Files\a-PyTorch-Tutorial-to-Image-Captioning>python caption.py --img=e:/paper.jpg --model=fake/BEST_checkpoint_coco_5_cap_per_img_5_min_
word_freq.pth.tar --word_map=fake/WORDMAP_coco_5_cap_per_img_5_min_word_freq.json --beam_size=5
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.Encoder’ has changed. you can retrieve the ori
ginal source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.conv.Conv2d’ has changed. you can re
trieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert th
e changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.batchnorm.BatchNorm2d’ has changed.
you can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to
revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torchvision.models.resnet.Bottleneck’ has changed. yo
u can retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to r
evert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.DecoderWithAttention’ has changed. you can ret
rieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the
changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘models.Attention’ has changed. you can retrieve the o
riginal source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.linear.Linear’ has changed. you can
retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert
the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.sparse.Embedding’ has changed. you c
an retrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to reve
rt the changes.
warnings.warn(msg, SourceChangeWarning)
C:\Anaconda3\lib\site-packages\torch\serialization.py:425: SourceChangeWarning: source code of class ‘torch.nn.modules.rnn.LSTMCell’ has changed. you can r
etrieve the original source code by accessing the object’s source attribute or set torch.nn.Module.dump_patches = True
and use the patch tool to revert t
he changes.
warnings.warn(msg, SourceChangeWarning)
Traceback (most recent call last):
File “caption.py”, line 222, in <module>
seq,alphas = caption_image_beam_search(encoder, decoder, args.img, word_map, args.beam_size)
File “caption.py”, line 45, in caption_image_beam_search
image = transform(img) # (3, 256, 256)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 60, in call
img = t(img)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\transforms.py”, line 163, in call
return F.normalize(tensor, self.mean, self.std, self.inplace)
File “C:\Anaconda3\lib\site-packages\torchvision\transforms\functional.py”, line 208, in normalize
tensor.sub_(mean[:, None, None]).div_(std[:, None, None])
RuntimeError: Expected object of type torch.cuda.FloatTensor but found type torch.FloatTensor for argument #4 ‘other’
Pytorch and python are installed according to the version you provide. Why does this happen? Thank you for your answer.
Issue Analytics
- State:
- Created 5 years ago
- Comments:9 (3 by maintainers)
Source-code Change Warning.
i get error after running caption.py file:::
here i set
torch.nn.Module.dump_patches=True
as per first error but both the time i am getting same output for every image.output is :: <start> a close up of a black and white background <end>
can you help me through this error and please you specifi the version of pytorch, torch, torchvision that is compitable with current source code. i think upgraded version of this package is remove or deprecated some functions.
@672401341 Hi, were you able to fix this?
It looks like the image (which is being normalized) is on the GPU, whereas the mean and standard deviation tensors are on the CPU. We’re supplying the mean and standard deviations as lists, so they’re converted to tensors by PyTorch internally. It’s weird – I don’t get the error when I try it on my computer.
You could try putting the image on the GPU after the normalization:
Let me know if this fixes it.
(You can ignore the other warnings, they’re only because some layer definitions were changed after the model was trained.)