captum icon indicating copy to clipboard operation
captum copied to clipboard

IMDB_TorchText_Interpret tutorial uses deprecated pytorch library version

Open antoinecomp opened this issue 2 years ago • 5 comments

I think the PyTorch version used in the IMDB_TorchText_Interpret tutorial is deprecated. Indeed, the tutorial uses a small subset of test data from IMDB dataset using torchtext:

TEXT = torchtext.data.Field(lower=True, tokenize='spacy')

then it uses .pad_token, as well as a method like .vocab.stoi. However all of these disappeared in pytorch 0.9.0. But even when downloading the former I got the following error on Google Colab:

---------------------------------------------------------------------------
OSError                                   Traceback (most recent call last)
[<ipython-input-2-2fdfbc0d174c>](https://localhost:8080/#) in <module>
----> 1 import torchtext
      2 TEXT = torchtext.data.Field(lower=True, tokenize='spacy')

3 frames
[/usr/lib/python3.7/ctypes/__init__.py](https://localhost:8080/#) in __init__(self, name, mode, handle, use_errno, use_last_error)
    362 
    363         if handle is None:
--> 364             self._handle = _dlopen(self._name, mode)
    365         else:
    366             self._handle = handle

OSError: /usr/local/lib/python3.7/dist-packages/torchtext/_torchtext.so: undefined symbol: _ZNK3c104Type14isSubtypeOfExtESt10shared_ptrIS0_EPSo

antoinecomp avatar Aug 30 '22 13:08 antoinecomp

Hi @antoinecomp, thank you for bringing it up. Yes, we need to update the versions. Do you mean pytorch or torchtext version ?

NarineK avatar Aug 30 '22 16:08 NarineK

Hi @NarineK ! torchtext sorry !

antoinecomp avatar Aug 31 '22 13:08 antoinecomp

Yes I'm having difficulty here as well. Can't get this notebook to run on my machine, perhaps due to slightly different versions of torchtext, pytorch, etc. even though I tried to ensure that the setup was done correctly. Would hugely appreciate an update to the notebook and more detailed documentation on the third party software used!

lkurlandski avatar Oct 01 '22 14:10 lkurlandski

captum 0.5.0 spacy 3.4.3 torch 1.13.0+cu117 torchtext 0.14.0

model = torch.load('models/imdb-model-cnn-large.pt')

/home/george/.local/lib/python3.10/site-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.sparse.Embedding' 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) /home/george/.local/lib/python3.10/site-packages/torch/serialization.py:868: SourceChangeWarning: source code of class 'torch.nn.modules.container.ModuleList' 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) ...

Claus1 avatar Dec 02 '22 21:12 Claus1