Giter VIP home page Giter VIP logo

interpretml / interpret-text Goto Github PK

View Code? Open in Web Editor NEW
402.0 19.0 67.0 10.57 MB

A library that incorporates state-of-the-art explainers for text-based machine learning models and visualizes the result with a built-in dashboard.

License: MIT License

Python 71.08% TypeScript 3.02% JavaScript 1.01% HTML 0.05% Jupyter Notebook 24.15% Shell 0.02% PowerShell 0.13% SCSS 0.54%
text-interpretability explainer nlp-models jupyter-notebook visualization-dashboard nlp-scenarios data-scientists glass-box-explainers linear-models grey-box-explainers

interpret-text's People

Contributors

anishpimpley avatar bethz avatar chhetri22 avatar dependabot[bot] avatar eedeleon avatar enosakhare avatar exoblivione avatar hwangshannon avatar imatiach-msft avatar janhavi13 avatar microsoftopensource avatar minthigpen avatar mohsinposts avatar msftgits avatar rebeccaj1211 avatar riedgar-ms avatar star1327p avatar wamartin-aml avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

interpret-text's Issues

[Classical Explainer] explain_local should support predicted_label as an optional parameter.

The visualization dashboard always defaulted to "fiction" label

repro:
document = "Demonstrating Product Reliability Indicates the Product Is Ready for Production"
local_explanation = explainer.explain_local(document)
local_explanation._predicted_label = None

Solution:

0 if name == explanation._predicted_label else 1 for name in classNames

Pass the predicted_label while creating local_explanation in explain_local.

Vocab Error when running 'Interpreting Classical Text Classification models' Notebook

Using a clean Python 3.7 environment on Ubuntu, and installing interpret-text using pip, I am hitting an error when I try to walk through the 'Interpreting Classical Text Classification models' notebook; I have made no changes to the code.

When attempting to fit the model, on the line:

classifier, best_params = explainer.fit(X_train, y_train)

I get the following error:

/anaconda/envs/interpret/lib/python3.7/site-packages/sklearn/feature_extraction/text.py:489: UserWarning: The parameter 'token_pattern' will not be used since 'tokenizer' is not None'
  warnings.warn("The parameter 'token_pattern' will not be used"
---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-11-47f4fc43855d> in <module>
----> 1 classifier, best_params = explainer.fit(X_train, y_train)

/anaconda/envs/interpret/lib/python3.7/site-packages/interpret_text/experimental/classical.py in fit(self, X_str, y_train)
     92         :rtype: list
     93         """
---> 94         X_train = self._encode(X_str)
     95         if self.is_trained is False:
     96             if self.model is None:

/anaconda/envs/interpret/lib/python3.7/site-packages/interpret_text/experimental/classical.py in _encode(self, X_str)
     61         :rtype: array_like (ndarray, pandas dataframe). Same rows as X_str
     62         """
---> 63         X_vec, _ = self.preprocessor.encode_features(X_str)
     64         return X_vec
     65 

/anaconda/envs/interpret/lib/python3.7/site-packages/interpret_text/experimental/common/utils_classical.py in encode_features(self, X_str, needs_fit, keep_ids)
    129         # needs_fit will be set to true if encoder is not already trained
    130         if needs_fit is True:
--> 131             self.vectorizer.fit(X_str)
    132         if isinstance(X_str, str):
    133             X_str = [X_str]

/anaconda/envs/interpret/lib/python3.7/site-packages/sklearn/feature_extraction/text.py in fit(self, raw_documents, y)
   1167         """
   1168         self._warn_for_unused_params()
-> 1169         self.fit_transform(raw_documents)
   1170         return self
   1171 

/anaconda/envs/interpret/lib/python3.7/site-packages/sklearn/feature_extraction/text.py in fit_transform(self, raw_documents, y)
   1201 
   1202         vocabulary, X = self._count_vocab(raw_documents,
-> 1203                                           self.fixed_vocabulary_)
   1204 
   1205         if self.binary:

/anaconda/envs/interpret/lib/python3.7/site-packages/sklearn/feature_extraction/text.py in _count_vocab(self, raw_documents, fixed_vocab)
   1131             vocabulary = dict(vocabulary)
   1132             if not vocabulary:
-> 1133                 raise ValueError("empty vocabulary; perhaps the documents only"
   1134                                  " contain stop words")
   1135 

ValueError: empty vocabulary; perhaps the documents only contain stop words

Am I missing something obvious here?

Issue with Introspective Rationale Explainer with RNN

when using explainer.fit(df_train, df_test) i am getting following error
RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.

API Inconsistencies with interpretml/interpret library

Looking through the API differences between interpret-text-contrib and intpret we found 3 explain_local calls in interpret-text-contrib:

  • def explain_local(self, input_text, abs_sum_to_one=False):

  • def explain_local(self, text: str, **kwargs) -> _create_local_explanation:

  • def explain_local(self, text, classes=None, predicted_label=None, true_label=None, num_iteration=150):

Interpret's spec is more like:

  • def explain_local(self, X, y=None, **kwargs)

Will be updating the explain_local calls to the above spec to improve interop with interpret. The spec is still not exact, but a push in the right direction.

We will also explicitly fail for calls of a list instead of the current failure mode. Future support for a list of strings is on the roadmap.

Using bert-base-chinese causes CUDA error: device-side assert triggered

I am following the
Text Classification of MultiNLI Sentences using BERT notebook to interpret BERT classification work. When I changed the line LANGUAGE = Language.ENGLISH to LANGUAGE = Language.CHINESE, indicating to use the bert-base-chinese pre-trained model, the following error occured:

interpreter_unified.explain_local('', 'fiction')
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
~/Projects/interpret-text/notebooks/text_classification/unified_info_explainer_sample.py in 
----> 1 interpreter_unified.explain_local('', 'fiction')

~/miniconda3/envs/interpret_gpu/lib/python3.7/site-packages/interpret_text/experimental/unified_information.py in explain_local(self, X, y, name, num_iteration)
     95         X = _validate_X(X)
     96 
---> 97         embedded_input, parsed_sentence = _get_single_embedding(self.model, X, self.device)
     98         self.input_embeddings = embedded_input
     99         self.parsed_sentence = parsed_sentence

~/miniconda3/envs/interpret_gpu/lib/python3.7/site-packages/interpret_text/experimental/common/utils_unified.py in _get_single_embedding(model, text, device)
     33     words = [BertTokens.CLS] + tokenizer.tokenize(text) + [BertTokens.SEP]
     34     tokenized_ids = tokenizer.convert_tokens_to_ids(words)
---> 35     token_tensor = torch.tensor([tokenized_ids], device=device)
     36     embedding = model.bert.embeddings(token_tensor)[0]
     37     return embedding, words

I tried with the original dataset as used in the example notebook, and also tried with my own dataset with Chinese texts. Both resulted in the above error. There was no issue when using multilingual model.

Python 3.8 not compatible

I got dependencies conflicts when trying to create interpret_cpu virtual environement. I had to manually set python version to 3.7 on the yaml file to fix the problem.

Error while installing from setup.py

Getting 'interpret_text\widget\static\extension.js' while installing the library for running the notebook.

Error text: "error: can't copy 'interpret_text\widget\static\extension.js': doesn't exist or not a regular file"

Zero shot classifier with interpret text

Hi

I am using the huggingface transformers zero shot classification pipeline.

from transformers import pipeline
classifier = pipeline("zero-shot-classification",
                      model="facebook/bart-large-mnli")
sequence_to_classify = "one day I will see the world"
candidate_labels = ['travel', 'cooking', 'dancing']
classifier(sequence_to_classify, candidate_labels)

I would like to use the word importance feature of the interpret-text module to get the important words for the predicted label.

Can you please help on how I could do this ?

Thanks,
Subham

AttributeError: 'LogisticRegression' object has no attribute 'encode_features'

The document mentioned that we can pass any linear or tree model to ClassicTreeExplainer. All code works smoothly if we use the classifier from interpret-text, however, if we train a logistic regression on the outside, and try to pass it to classic explainer, it gives the above error.

Now, the question is, do the explainers actually support any outside model or it has to be fitted from classifiers inside interpret-text package?

My code:

n = X_train.shape[0]
vec = TfidfVectorizer(ngram_range=(1,2), tokenizer=tokenize, min_df=3, max_df=0.9, strip_accents='unicode', use_idf=1, smooth_idf=1, sublinear_tf=1 )
trn_term_doc = vec.fit_transform(X_train)
test_term_doc = vec.transform(X_test)
m = LogisticRegression()
model1=m.fit(x,y_train)
predicted_label = model1.predict(test_x)
explainer = ClassicalTextExplainer(model1)
local_explanation = explainer.explain_local(X_test.iloc[0], predicted_label[0])

The last line results in the error


AttributeError Traceback (most recent call last)
in
----> 1 local_explanation = explainer.explain_local(X_test.iloc[0], predicted_label[0])

~/anaconda3/envs/fairlearn/lib/python3.6/site-packages/interpret_text/experimental/classical.py in explain_local(self, X, y, name)
143 X = _validate_X(X)
144
--> 145 [encoded_text, _] = self.preprocessor.encode_features(
146 X, needs_fit=False
147 )

AttributeError: 'LogisticRegression' object has no attribute 'encode_features'

X_test is the actual texts in the test data, X_test.iloc[0] is actually "Thank you for correcting my typo in Thomas Pooley. I am the world's worst proofreader!"

Just want to find an answer

Windows builds slow

The Windows builds in the new pipelines are several times slower than the Linux and MacOS ones. This needs to be investigated.

Install packages failed with OSError

Hi experts,

Install packages (Jupyter Widget) failed with the following error on Azure ML Compute Instance. Any workaround on this ?

(interpret_gpu) azureuser@interpretml:/mnt/batch/tasks/shared/LS_root/mounts/clusters/interpretml/code/Users/keonabut/interpret-text/python$ jupyter nbextension install interpret_text.experimental.widget --py --sys-prefix
Installing /mnt/batch/tasks/shared/LS_root/mounts/clusters/interpretml/code/Users/keonabut/interpret-text/python/interpret_text/experimental/widget/static -> interpret-text-widget
Up to date: /anaconda/envs/interpret_gpu/share/jupyter/nbextensions/interpret-text-widget/extension.js.map
Copying: /mnt/batch/tasks/shared/LS_root/mounts/clusters/interpretml/code/Users/keonabut/interpret-text/python/interpret_text/experimental/widget/static/index.js -> /anaconda/envs/interpret_gpu/share/jupyter/nbextensions/interpret-text-widget/index.js
Traceback (most recent call last):
  File "/anaconda/envs/interpret_gpu/bin/jupyter-nbextension", line 11, in <module>
    sys.exit(main())
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/jupyter_core/application.py", line 270, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/traitlets/config/application.py", line 664, in launch_instance
    app.start()
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 983, in start
    super(NBExtensionApp, self).start()
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/jupyter_core/application.py", line 259, in start
    self.subapp.start()
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 711, in start
    self.install_extensions()
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 690, in install_extensions
    **kwargs
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 220, in install_nbextension_python
    destination=dest, logger=logger
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 191, in install_nbextension
    _maybe_copy(src, dest_file, logger=logger)
  File "/anaconda/envs/interpret_gpu/lib/python3.6/site-packages/notebook/nbextensions.py", line 1041, in _maybe_copy
    shutil.copy2(src, dest)
  File "/anaconda/envs/interpret_gpu/lib/python3.6/shutil.py", line 264, in copy2
    copystat(src, dst, follow_symlinks=follow_symlinks)
  File "/anaconda/envs/interpret_gpu/lib/python3.6/shutil.py", line 229, in copystat
    _copyxattr(src, dst, follow_symlinks=follow)
  File "/anaconda/envs/interpret_gpu/lib/python3.6/shutil.py", line 157, in _copyxattr
    names = os.listxattr(src, follow_symlinks=follow_symlinks)
OSError: [Errno 38] Function not implemented: '/mnt/batch/tasks/shared/LS_root/mounts/clusters/interpretml/code/Users/keonabut/interpret-text/python/interpret_text/experimental/widget/static/index.js'

Thanks
Keita

Got an error when running the Rationale Explainer Sample Notebook (with `fixed_classifier` = False)

When trying to run the Introspective Rationale Explainer Sample Notebook (after going around #150 by using specifying CUDA=True), this error came up:

RuntimeError: one of the variables needed for gradient computation has been modified by an in-place operation: [torch.FloatTensor [50, 150]], which is output 0 of TBackward, is at version 9; expected version 8 instead.

This time the problem seems to be from training the classifier used to feed label to the generator (specifically, this block of code). The notebook can run to the end after commenting out this block (line 232 to 235).

(Update: an alternative workaround is to set fixed_classifier=True and pretrain_cls=True in model_config. This should pre-train the classifier and freeze the classifier weights during generator training.)

(I used PyTorch 1.7 to run the notebook.)

Issue with Introspective Rationale Explainer for BERT on text

explainer.fit(df_train, df_test) is giving error
'RuntimeError: view size is not compatible with input tensor's size and stride (at least one dimension spans across two contiguous subspaces). Use .reshape(...) instead.'
I'm getting this error on running the example notebook as well as trying on my own data

fp16 compatibility StopIteration on Multiple GPU's: Text Classification of MultiNLI Sentences using BERT

Hello!
I hope you're doing great. On the other hand, I had this issue while running this jupyter notebook Text Classification of MultiNLI Sentences using BERT.
Environment: On-Premises
Computer: Macbook Pro 16"
CPU: intel i9 9980HK
RAM: 64GB
GPU: 2 x TITAN RTX 24GB in RAM
GPU Enclosure: 2 x Razer Core X Chrome Thunderbold 3 (1 connected to the left and one connected to the right)
Conda Version: conda 4.8.3
Python Version: Python 3.7.7

Packages Installed:

Name                    Version                   Build  Channel
_anaconda_depends         2020.02                  py37_0
_pytorch_select           1.1.0                       cpu
_r-mutex                  1.0.0               anacondar_1
_tflow_select             2.1.0                       gpu
absl-py                   0.9.0                    py37_0
alabaster                 0.7.12                   py37_0
anaconda                  custom                   py37_1
anaconda-client           1.7.2                    py37_0
anaconda-project          0.8.4                      py_0
argh                      0.26.2                   py37_0
asn1crypto                1.3.0                    py37_0
astor                     0.8.0                    py37_0
astroid                   2.3.3                    py37_0
astropy                   4.0.1.post1      py37he774522_1
atomicwrites              1.4.0                      py_0
attrs                     19.3.0                     py_0
autopep8                  1.4.4                      py_0
babel                     2.8.0                      py_0
backcall                  0.1.0                    py37_0
backports                 1.0                        py_2
backports.shutil_get_terminal_size 1.0.0                    py37_2
bcrypt                    3.1.7            py37he774522_0
beautifulsoup4            4.9.0                    py37_0
bitarray                  1.2.1            py37he774522_0
bkcharts                  0.2                      py37_0
blas                      1.0                         mkl
bleach                    3.1.4                      py_0
blinker                   1.4                      py37_0
blis                      0.4.1                    pypi_0    pypi
blosc                     1.16.3               h7bd577a_0
bokeh                     2.0.2                    py37_0
boto                      2.49.0                   py37_0
boto3                     1.13.13                  pypi_0    pypi
botocore                  1.16.13                  pypi_0    pypi
bottleneck                1.3.2            py37h2a96729_0
brotli                    1.0.7                    pypi_0    pypi
bzip2                     1.0.8                he774522_0
ca-certificates           2020.4.5.1           hecc5488_0    conda-forge
cached-property           1.5.1                    pypi_0    pypi
cachetools                3.1.1                      py_0
catalogue                 1.0.0                    pypi_0    pypi
certifi                   2020.4.5.1       py37hc8dfbb8_0    conda-forge
cffi                      1.14.0           py37h7a1dbc1_0
chardet                   3.0.4                 py37_1003
click                     7.1.2                      py_0
cloudpickle               1.4.1                      py_0
clyent                    1.2.2                    py37_1
colorama                  0.4.3                      py_0
comtypes                  1.1.7                    py37_0
console_shortcut          0.1.1                         4
contextlib2               0.6.0.post1                py_0
cryptography              2.9.2            py37h7a1dbc1_0
cssselect                 1.1.0                    pypi_0    pypi
cudatoolkit               10.1.243             h74a9793_0
cudnn                     7.6.5                cuda10.1_0
curl                      7.69.1               h2a8f88b_0
cycler                    0.10.0                   py37_0
cymem                     2.0.3                    pypi_0    pypi
cython                    0.29.17          py37ha925a31_0
cytoolz                   0.10.1           py37he774522_0
dash                      1.12.0                   pypi_0    pypi
dash-core-components      1.10.0                   pypi_0    pypi
dash-cytoscape            0.1.1                    pypi_0    pypi
dash-html-components      1.0.3                    pypi_0    pypi
dash-renderer             1.4.1                    pypi_0    pypi
dash-table                4.7.0                    pypi_0    pypi
dask                      2.16.0                     py_0
dask-core                 2.16.0                     py_0
decorator                 4.4.2                      py_0
defusedxml                0.6.0                      py_0
diff-match-patch          20181111                   py_0
dill                      0.3.1.1                  pypi_0    pypi
distributed               2.16.0                   py37_0
docutils                  0.15.2                   pypi_0    pypi
entrypoints               0.3                      py37_0
et_xmlfile                1.0.1                    py37_0
fastcache                 1.1.0            py37he774522_0
filelock                  3.0.12                     py_0
flake8                    3.7.9                    py37_0
flask                     1.1.2                    pypi_0    pypi
flask-compress            1.5.0                    pypi_0    pypi
freetype                  2.9.1                ha9979f8_1
fsspec                    0.7.1                      py_0
future                    0.18.2                   py37_0
gast                      0.2.2                    py37_0
get_terminal_size         1.0.0                h38e98db_0
gevent                    20.5.0                   pypi_0    pypi
glob2                     0.7                        py_0
google-auth               1.14.1                     py_0
google-auth-oauthlib      0.4.1                      py_2
google-pasta              0.2.0                      py_0
greenlet                  0.4.15           py37hfa6e2cd_0
grpcio                    1.27.2           py37h351948d_0
h5py                      2.10.0           py37h5e291fa_0
hdf5                      1.10.4               h7ebc959_0
heapdict                  1.0.1                      py_0
html5lib                  1.0.1                    py37_0
hypothesis                5.11.0                     py_0
icc_rt                    2019.0.0             h0cc432a_1
icu                       58.2                 ha925a31_3
idna                      2.9                        py_1
imagecodecs               2020.2.18                pypi_0    pypi
imageio                   2.8.0                      py_0
imagesize                 1.2.0                      py_0
importlib_metadata        1.5.0                    py37_0
intel-openmp              2020.1                      216
interpret                 0.1.22                   pypi_0    pypi
interpret-community       0.11.1                   pypi_0    pypi
interpret-core            0.1.21                   pypi_0    pypi
interpret-text            0.1.1                    pypi_0    pypi
intervaltree              3.0.2                      py_0
ipykernel                 5.1.4            py37h39e3cac_0
ipython                   7.13.0           py37h5ca1d4c_0
ipython_genutils          0.2.0                    py37_0
ipywidgets                7.5.1                      py_0
isort                     4.3.21                   py37_0
itsdangerous              1.1.0                    py37_0
jdcal                     1.4.1                      py_0
jedi                      0.15.2                   py37_0
jinja2                    2.11.2                     py_0
jmespath                  0.10.0                   pypi_0    pypi
joblib                    0.14.1                     py_0
jpeg                      9b                   hb83a4c4_2
json5                     0.9.4                      py_0
jsonschema                3.2.0                    py37_0
jupyter                   1.0.0                    py37_7
jupyter_client            6.1.3                      py_0
jupyter_console           6.1.0                      py_0
jupyter_contrib_core      0.3.3                      py_2    conda-forge
jupyter_contrib_nbextensions 0.5.1                    py37_0    conda-forge
jupyter_core              4.6.3                    py37_0
jupyter_highlight_selected_word 0.2.0                 py37_1000    conda-forge
jupyter_latex_envs        1.4.4                 py37_1000    conda-forge
jupyter_nbextensions_configurator 0.4.1                    py37_0    conda-forge
jupyterlab                1.2.6              pyhf63ae98_0
jupyterlab_server         1.1.1                      py_0
keras                     2.3.1                         0
keras-applications        1.0.8                      py_0
keras-base                2.3.1                    py37_0
keras-preprocessing       1.1.0                      py_1
keyring                   21.1.1                   py37_2
kiwisolver                1.2.0            py37h74a9793_0
krb5                      1.17.1               hc04afaa_0
lazy-object-proxy         1.4.3            py37he774522_0
libarchive                3.3.3                h0643e63_5
libcurl                   7.69.1               h2a8f88b_0
libiconv                  1.15                 h1df5818_7
liblief                   0.10.1               ha925a31_0
libpng                    1.6.37               h2a8f88b_0
libprotobuf               3.11.4               h7bd577a_0
libsodium                 1.0.16               h9d3ae62_0
libspatialindex           1.9.3                h33f27b4_0
libssh2                   1.9.0                h7a1dbc1_1
libtiff                   4.1.0                h56a325e_0
libxml2                   2.9.9                h464c3ec_0
libxslt                   1.1.33               h579f668_0
lime                      0.2.0.0                  pypi_0    pypi
llvmlite                  0.32.1           py37ha925a31_0
locket                    0.2.0                    py37_1
lxml                      4.5.1                    pypi_0    pypi
lz4-c                     1.8.1.2              h2fa13f4_0
lzo                       2.10                 he774522_2
m2w64-bwidget             1.9.10                        2
m2w64-bzip2               1.0.6                         6
m2w64-expat               2.1.1                         2
m2w64-fftw                3.3.4                         6
m2w64-flac                1.3.1                         3
m2w64-gcc-libgfortran     5.3.0                         6
m2w64-gcc-libs            5.3.0                         7
m2w64-gcc-libs-core       5.3.0                         7
m2w64-gettext             0.19.7                        2
m2w64-gmp                 6.1.0                         2
m2w64-gsl                 2.1                           2
m2w64-libiconv            1.14                          6
m2w64-libjpeg-turbo       1.4.2                         3
m2w64-libogg              1.3.2                         3
m2w64-libpng              1.6.21                        2
m2w64-libsndfile          1.0.26                        2
m2w64-libsodium           1.0.10                        2
m2w64-libtiff             4.0.6                         2
m2w64-libvorbis           1.3.5                         2
m2w64-libwinpthread-git   5.0.0.4634.697f757               2
m2w64-libxml2             2.9.3                         4
m2w64-mpfr                3.1.4                         4
m2w64-openblas            0.2.19                        1
m2w64-pcre                8.38                          2
m2w64-speex               1.2rc2                        3
m2w64-speexdsp            1.2rc3                        3
m2w64-tcl                 8.6.5                         3
m2w64-tk                  8.6.5                         3
m2w64-tktable             2.10                          5
m2w64-wineditline         2.101                         5
m2w64-xz                  5.2.2                         2
m2w64-zeromq              4.1.4                         2
m2w64-zlib                1.2.8                        10
markdown                  3.1.1                    py37_0
markupsafe                1.1.1            py37he774522_0
matplotlib                3.1.3                    py37_0
matplotlib-base           3.1.3            py37h64f37c6_0
mccabe                    0.6.1                    py37_1
menuinst                  1.4.16           py37he774522_0
mistune                   0.8.4            py37he774522_0
mkl                       2020.1                      216
mkl-service               2.3.0            py37hb782905_0
mkl_fft                   1.0.15           py37h14836fe_0
mkl_random                1.1.0            py37h675688f_0
mock                      4.0.2                      py_0
more-itertools            8.2.0                      py_0
mpmath                    1.1.0                    py37_0
msgpack-python            1.0.0            py37h74a9793_1
msys2-conda-epoch         20160418                      1
multipledispatch          0.6.0                    py37_0
murmurhash                1.0.2                    pypi_0    pypi
nbconvert                 5.6.1                    py37_0
nbformat                  5.0.6                      py_0
networkx                  2.4                        py_0
ninja                     1.9.0            py37h74a9793_0
nltk                      3.4.5                    py37_0
nose                      1.3.7                    py37_2
notebook                  6.0.3                    py37_0
numba                     0.49.1           py37h47e9c7a_0
numexpr                   2.7.1            py37h25d0782_0
numpy                     1.18.1           py37h93ca92e_0
numpy-base                1.18.1           py37hc3f5095_1
numpydoc                  0.9.2                      py_0
oauthlib                  3.1.0                      py_0
olefile                   0.46                     py37_0
openpyxl                  3.0.3                      py_0
openssl                   1.1.1g               he774522_0    conda-forge
opt_einsum                3.1.0                      py_0
packaging                 20.4                     pypi_0    pypi
pandas                    1.0.3            py37h47e9c7a_0
pandoc                    2.2.3.2                       0
pandocfilters             1.4.2                    py37_1
paramiko                  2.7.1                      py_0
parsel                    1.6.0                    pypi_0    pypi
parso                     0.5.2                      py_0
partd                     1.1.0                      py_0
path                      13.1.0                   py37_0
path.py                   12.4.0                        0
pathlib2                  2.3.5                    py37_0
pathtools                 0.1.2                      py_1
patsy                     0.5.1                    py37_0
pep8                      1.7.1                    py37_0
pexpect                   4.8.0                    py37_0
pickleshare               0.7.5                    py37_0
pillow                    5.4.1                    pypi_0    pypi
pip                       20.0.2                   py37_3
pkginfo                   1.5.0.1                  py37_0
plac                      1.1.3                    pypi_0    pypi
plotly                    4.7.1                    pypi_0    pypi
pluggy                    0.13.1                   py37_0
ply                       3.11                     py37_0
powershell_shortcut       0.0.1                         3
preshed                   3.0.2                    pypi_0    pypi
prometheus_client         0.7.1                      py_0
prompt-toolkit            3.0.4                      py_0
prompt_toolkit            3.0.4                         0
protobuf                  3.11.4           py37h33f27b4_0
psutil                    5.7.0            py37he774522_0
py                        1.8.1                      py_0
py-lief                   0.10.1           py37ha925a31_0
pyasn1                    0.4.8                      py_0
pyasn1-modules            0.2.7                      py_0
pycodestyle               2.5.0                    py37_0
pycosat                   0.6.3            py37he774522_0
pycparser                 2.20                       py_0
pycrypto                  2.6.1            py37hfa6e2cd_9
pycurl                    7.43.0.5         py37h7a1dbc1_0
pydantic                  1.5.1                    pypi_0    pypi
pydocstyle                4.0.1                      py_0
pyflakes                  2.1.1                    py37_0
pygments                  2.6.1                      py_0
pyjwt                     1.7.1                    py37_0
pylint                    2.4.4                    py37_0
pynacl                    1.3.0            py37h62dcd97_0
pyodbc                    4.0.30           py37ha925a31_0
pyopenssl                 19.1.0                   py37_0
pyparsing                 2.4.7                      py_0
pyqt                      5.9.2            py37h6538335_2
pyreadline                2.1                      py37_1
pyrsistent                0.16.0           py37he774522_0
pysocks                   1.7.1                    py37_0
pytables                  3.6.1            py37h1da0976_0
pytest                    5.4.2                    py37_0
pytest-arraydiff          0.3              py37h39e3cac_0
pytest-astropy            0.8.0                      py_0
pytest-astropy-header     0.1.2                      py_0
pytest-doctestplus        0.5.0                      py_0
pytest-openfiles          0.5.0                      py_0
pytest-remotedata         0.3.2                    py37_0
python                    3.7.7                h81c818b_4
python-dateutil           2.8.1                      py_0
python-jsonrpc-server     0.3.4                      py_0
python-language-server    0.31.10                  py37_0
python-libarchive-c       2.9                        py_0
python_abi                3.7                     1_cp37m    conda-forge
pytorch                   1.5.0           py3.7_cuda101_cudnn7_0    pytorch
pytorch-pretrained-bert   0.6.2                    pypi_0    pypi
pytz                      2020.1                     py_0
pywavelets                1.1.1            py37he774522_0
pywin32                   227              py37he774522_1
pywin32-ctypes            0.2.0                 py37_1000
pywinpty                  0.5.7                    py37_0
pyyaml                    5.3.1            py37he774522_0
pyzmq                     18.1.1           py37ha925a31_0
qdarkstyle                2.8.1                      py_0
qt                        5.9.7            vc14h73c81de_0
qtawesome                 0.7.0                      py_0
qtconsole                 4.7.4                      py_0
qtpy                      1.9.0                      py_0
r-askpass                 1.0                       r36_0
r-assertthat              0.2.1             r36h6115d3f_0
r-backports               1.1.4             r36h6115d3f_0
r-base                    3.6.1                hf18239d_1
r-base64enc               0.1_3             r36h6115d3f_4
r-bh                      1.69.0_1          r36h6115d3f_0
r-boot                    1.3_20            r36h6115d3f_0
r-broom                   0.5.2             r36h6115d3f_0
r-callr                   3.2.0             r36h6115d3f_0
r-caret                   6.0_83            r36h6115d3f_0
r-cellranger              1.1.0             r36h6115d3f_0
r-class                   7.3_15            r36h6115d3f_0
r-cli                     1.1.0             r36h6115d3f_0
r-clipr                   0.6.0             r36h6115d3f_0
r-cluster                 2.0.8             r36h6115d3f_0
r-codetools               0.2_16            r36h6115d3f_0
r-colorspace              1.4_1             r36h6115d3f_0
r-crayon                  1.3.4             r36h6115d3f_0
r-curl                    3.3               r36h6115d3f_0
r-data.table              1.12.2            r36h6115d3f_0
r-dbi                     1.0.0             r36h6115d3f_0
r-dbplyr                  1.4.0             r36h6115d3f_0
r-dichromat               2.0_0             r36h6115d3f_4
r-digest                  0.6.18            r36h6115d3f_0
r-dplyr                   0.8.0.1           r36h6115d3f_0
r-ellipsis                0.1.0             r36h6115d3f_0
r-essentials              3.6.0                     r36_0
r-evaluate                0.13              r36h6115d3f_0
r-fansi                   0.4.0             r36h6115d3f_0
r-forcats                 0.4.0             r36h6115d3f_0
r-foreach                 1.4.4             r36h6115d3f_0
r-foreign                 0.8_71            r36h6115d3f_0
r-formatr                 1.6               r36h6115d3f_0
r-fs                      1.2.7             r36h6115d3f_0
r-generics                0.0.2             r36h6115d3f_0
r-ggplot2                 3.1.1             r36h6115d3f_0
r-glmnet                  2.0_16            r36h6115d3f_0
r-glue                    1.3.1             r36h6115d3f_0
r-gower                   0.2.0             r36h6115d3f_0
r-gtable                  0.3.0             r36h6115d3f_0
r-haven                   2.1.0             r36h6115d3f_0
r-hexbin                  1.27.2            r36h6115d3f_0
r-highr                   0.8               r36h6115d3f_0
r-hms                     0.4.2             r36h6115d3f_0
r-htmltools               0.3.6             r36h6115d3f_0
r-htmlwidgets             1.3               r36h6115d3f_0
r-httpuv                  1.5.1             r36h6115d3f_0
r-httr                    1.4.0             r36h6115d3f_0
r-ipred                   0.9_8             r36h6115d3f_0
r-irdisplay               0.7.0             r36h6115d3f_0
r-irkernel                0.8.15                    r36_0
r-iterators               1.0.10            r36h6115d3f_0
r-jsonlite                1.6               r36h6115d3f_0
r-kernsmooth              2.23_15           r36h6115d3f_4
r-knitr                   1.22              r36h6115d3f_0
r-labeling                0.3               r36h6115d3f_4
r-later                   0.8.0             r36h6115d3f_0
r-lattice                 0.20_38           r36h6115d3f_0
r-lava                    1.6.5             r36h6115d3f_0
r-lazyeval                0.2.2             r36h6115d3f_0
r-lubridate               1.7.4             r36h6115d3f_0
r-magrittr                1.5               r36h6115d3f_4
r-maps                    3.3.0             r36h6115d3f_0
r-markdown                0.9               r36h6115d3f_0
r-mass                    7.3_51.3          r36h6115d3f_0
r-matrix                  1.2_17            r36h6115d3f_0
r-mgcv                    1.8_28            r36h6115d3f_0
r-mime                    0.6               r36h6115d3f_0
r-modelmetrics            1.2.2             r36h6115d3f_0
r-modelr                  0.1.4             r36h6115d3f_0
r-munsell                 0.5.0             r36h6115d3f_0
r-nlme                    3.1_139           r36h6115d3f_0
r-nnet                    7.3_12            r36h6115d3f_0
r-numderiv                2016.8_1          r36h6115d3f_0
r-openssl                 1.3               r36h6115d3f_0
r-pbdzmq                  0.3_3             r36h6115d3f_0
r-pillar                  1.3.1             r36h6115d3f_0
r-pkgconfig               2.0.2             r36h6115d3f_0
r-plogr                   0.2.0             r36h6115d3f_0
r-plyr                    1.8.4             r36h6115d3f_0
r-prettyunits             1.0.2             r36h6115d3f_0
r-processx                3.3.0             r36h6115d3f_0
r-prodlim                 2018.04.18        r36h6115d3f_0
r-progress                1.2.0             r36h6115d3f_0
r-promises                1.0.1             r36h6115d3f_0
r-ps                      1.3.0             r36h6115d3f_0
r-purrr                   0.3.2             r36h6115d3f_0
r-quantmod                0.4_14            r36h6115d3f_0
r-r6                      2.4.0             r36h6115d3f_0
r-randomforest            4.6_14            r36h6115d3f_0
r-rbokeh                  0.6.3                     r36_0
r-rcolorbrewer            1.1_2             r36h6115d3f_0
r-rcpp                    1.0.1             r36h6115d3f_0
r-rcpproll                0.3.0             r36h6115d3f_0
r-readr                   1.3.1             r36h6115d3f_0
r-readxl                  1.3.1             r36h6115d3f_0
r-recipes                 0.1.5             r36h6115d3f_0
r-recommended             3.6.0                     r36_0
r-rematch                 1.0.1             r36h6115d3f_0
r-repr                    0.19.2            r36h6115d3f_0
r-reprex                  0.2.1             r36h6115d3f_0
r-reshape2                1.4.3             r36h6115d3f_0
r-rlang                   0.3.4             r36h6115d3f_0
r-rmarkdown               1.12              r36h6115d3f_0
r-rpart                   4.1_15            r36h6115d3f_0
r-rstudioapi              0.10              r36h6115d3f_0
r-rvest                   0.3.3             r36h6115d3f_0
r-scales                  1.0.0             r36h6115d3f_0
r-selectr                 0.4_1             r36h6115d3f_0
r-shiny                   1.3.2             r36h6115d3f_0
r-sourcetools             0.1.7             r36h6115d3f_0
r-spatial                 7.3_11            r36h6115d3f_4
r-squarem                 2017.10_1         r36h6115d3f_0
r-stringi                 1.4.3             r36h6115d3f_0
r-stringr                 1.4.0             r36h6115d3f_0
r-survival                2.44_1.1          r36h6115d3f_0
r-sys                     3.2               r36h6115d3f_0
r-tibble                  2.1.1             r36h6115d3f_0
r-tidyr                   0.8.3             r36h6115d3f_0
r-tidyselect              0.2.5             r36h6115d3f_0
r-tidyverse               1.2.1             r36h6115d3f_0
r-timedate                3043.102          r36h6115d3f_0
r-tinytex                 0.12              r36h6115d3f_0
r-ttr                     0.23_4            r36h6115d3f_0
r-utf8                    1.1.4             r36h6115d3f_0
r-uuid                    0.1_2             r36h6115d3f_4
r-viridislite             0.3.0             r36h6115d3f_0
r-whisker                 0.3_2             r36h6115d3f_4
r-withr                   2.1.2             r36h6115d3f_0
r-xfun                    0.6               r36h6115d3f_0
r-xml2                    1.2.0             r36h6115d3f_0
r-xtable                  1.8_4             r36h6115d3f_0
r-xts                     0.11_2            r36h6115d3f_0
r-yaml                    2.2.0             r36h6115d3f_0
r-zoo                     1.8_5             r36h6115d3f_0
regex                     2020.5.14                pypi_0    pypi
requests                  2.23.0                   py37_0
requests-oauthlib         1.3.0                      py_0
retrying                  1.3.3                    pypi_0    pypi
rope                      0.17.0                     py_0
rsa                       4.0                        py_0
rtree                     0.9.4            py37h21ff451_1
ruamel_yaml               0.15.87          py37he774522_0
s3transfer                0.3.3                    pypi_0    pypi
sacremoses                0.0.43                   pypi_0    pypi
salib                     1.3.11                   pypi_0    pypi
scikit-image              0.17.2                   pypi_0    pypi
scikit-learn              0.22.1           py37h6288b17_0
scipy                     1.4.1            py37h9439919_0
scrapbook                 0.2.0                    pypi_0    pypi
seaborn                   0.10.1                     py_0
send2trash                1.5.0                    py37_0
sentencepiece             0.1.90                   pypi_0    pypi
setuptools                46.4.0                   py37_0
shap                      0.29.3                   pypi_0    pypi
simplegeneric             0.8.1                    py37_2
singledispatch            3.4.0.3                  py37_0
sip                       4.19.8           py37h6538335_0
six                       1.14.0                   py37_0
snappy                    1.1.7                h777316e_3
snowballstemmer           2.0.0                      py_0
sortedcollections         1.1.2                    py37_0
sortedcontainers          2.1.0                    py37_0
soupsieve                 2.0                        py_0
spacy                     2.2.4                    pypi_0    pypi
sphinx                    3.0.3                      py_0
sphinxcontrib             1.0                      py37_1
sphinxcontrib-applehelp   1.0.2                      py_0
sphinxcontrib-devhelp     1.0.2                      py_0
sphinxcontrib-htmlhelp    1.0.3                      py_0
sphinxcontrib-jsmath      1.0.1                      py_0
sphinxcontrib-qthelp      1.0.3                      py_0
sphinxcontrib-serializinghtml 1.1.4                      py_0
sphinxcontrib-websupport  1.2.1                      py_0
spyder                    4.1.3                    py37_0
spyder-kernels            1.9.1                    py37_0
sqlalchemy                1.3.16           py37he774522_0
sqlite                    3.31.1               h2a8f88b_1
srsly                     1.0.2                    pypi_0    pypi
statsmodels               0.11.0           py37he774522_0
sympy                     1.5.1                    py37_0
tbb                       2020.0               h74a9793_0
tblib                     1.6.0                      py_0
tensorboard               2.1.0                     py3_0
tensorflow                2.1.0           gpu_py37h7db9008_0
tensorflow-base           2.1.0           gpu_py37h55f5790_0
tensorflow-estimator      2.1.0              pyhd54b08b_0
tensorflow-gpu            2.1.0                h0d30ee6_0
termcolor                 1.1.0                    py37_1
terminado                 0.8.3                    py37_0
testpath                  0.4.4                      py_0
thinc                     7.4.0                    pypi_0    pypi
tifffile                  2020.5.11                pypi_0    pypi
tk                        8.6.8                hfa6e2cd_0
tokenizers                0.0.11                   pypi_0    pypi
toolz                     0.10.0                     py_0
torchvision               0.6.0                py37_cu101    pytorch
tornado                   6.0.4            py37he774522_1
tqdm                      4.46.0                     py_0
traitlets                 4.3.3                    py37_0
transformers              2.4.1                    pypi_0    pypi
treeinterpreter           0.2.2                    pypi_0    pypi
typing_extensions         3.7.4.1                  py37_0
ujson                     1.35             py37hfa6e2cd_0
unicodecsv                0.14.1                   py37_0
urllib3                   1.25.8                   py37_0
vc                        14.1                 h0510ff6_4
vs2015_runtime            14.16.27012          hf0eaf9b_1
w3lib                     1.22.0                   pypi_0    pypi
wasabi                    0.6.0                    pypi_0    pypi
watchdog                  0.10.2                   py37_0
wcwidth                   0.1.9                      py_0
webencodings              0.5.1                    py37_1
werkzeug                  1.0.1                    pypi_0    pypi
wheel                     0.34.2                   py37_0
widgetsnbextension        3.5.1                    py37_0
win_inet_pton             1.1.0                    py37_0
win_unicode_console       0.5                      py37_0
wincertstore              0.2                      py37_0
winpty                    0.4.3                         4
wrapt                     1.12.1           py37he774522_1
xgboost                   1.1.0                    pypi_0    pypi
xlrd                      1.2.0                    py37_0
xlsxwriter                1.2.8                      py_0
xlwings                   0.19.0                   py37_0
xlwt                      1.3.0                    py37_0
xz                        5.2.5                h62dcd97_0
yaml                      0.1.7                hc54c509_2
yapf                      0.28.0                     py_0
zeromq                    4.3.1                h33f27b4_3
zict                      2.0.0                      py_0
zipp                      3.1.0                      py_0
zlib                      1.2.11               h62dcd97_4
zstd                      1.3.7                h508b16e_0

When running this line:

with Timer() as t:
    classifier.fit(token_ids=tokens_train,
                    input_mask=mask_train,
                    labels=labels_train,    
                    num_epochs=NUM_EPOCHS,
                    batch_size=BATCH_SIZE,    
                    verbose=True)        
print("[Training time: {:.3f} hrs]".format(t.interval / 3600))

I got the following stack trace:

t_total value of -1 results in schedule not being applied
Iteration:   0%|          | 0/79 [00:00<?, ?it/s]

---------------------------------------------------------------------------
StopIteration                             Traceback (most recent call last)
<ipython-input-34-18e84990dbbe> in <module>
      5                     num_epochs=NUM_EPOCHS,
      6                     batch_size=BATCH_SIZE,
----> 7                     verbose=True)
      8 
      9 print("[Training time: {:.3f} hrs]".format(t.interval / 3600))

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\interpret_text\experimental\common\utils_bert.py in fit(self, token_ids, input_mask, labels, token_type_ids, num_gpus, num_epochs, batch_size, lr, warmup_proportion, verbose)
    550                     token_type_ids=token_type_ids_batch,
    551                     attention_mask=mask_batch,
--> 552                     labels=None,
    553                 )
    554                 loss = loss_func(y_h, y_batch).mean()

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\modules\module.py in __call__(self, *input, **kwargs)
    548             result = self._slow_forward(*input, **kwargs)
    549         else:
--> 550             result = self.forward(*input, **kwargs)
    551         for hook in self._forward_hooks.values():
    552             hook_result = hook(self, input, result)

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\parallel\data_parallel.py in forward(self, *inputs, **kwargs)
    153             return self.module(*inputs[0], **kwargs[0])
    154         replicas = self.replicate(self.module, self.device_ids[:len(inputs)])
--> 155         outputs = self.parallel_apply(replicas, inputs, kwargs)
    156         return self.gather(outputs, self.output_device)
    157 

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\parallel\data_parallel.py in parallel_apply(self, replicas, inputs, kwargs)
    163 
    164     def parallel_apply(self, replicas, inputs, kwargs):
--> 165         return parallel_apply(replicas, inputs, kwargs, self.device_ids[:len(replicas)])
    166 
    167     def gather(self, outputs, output_device):

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\parallel\parallel_apply.py in parallel_apply(modules, inputs, kwargs_tup, devices)
     83         output = results[i]
     84         if isinstance(output, ExceptionWrapper):
---> 85             output.reraise()
     86         outputs.append(output)
     87     return outputs

C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\_utils.py in reraise(self)
    393             # (https://bugs.python.org/issue2651), so we work around it.
    394             msg = KeyErrorMessage(msg)
--> 395         raise self.exc_type(msg)

StopIteration: Caught StopIteration in replica 0 on device 0.
Original Traceback (most recent call last):
  File "C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\parallel\parallel_apply.py", line 60, in _worker
    output = module(*input, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\pytorch_pretrained_bert\modeling.py", line 989, in forward
    _, pooled_output = self.bert(input_ids, token_type_ids, attention_mask, output_all_encoded_layers=False)
  File "C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\torch\nn\modules\module.py", line 550, in __call__
    result = self.forward(*input, **kwargs)
  File "C:\ProgramData\Anaconda3\envs\EmilioDL\lib\site-packages\pytorch_pretrained_bert\modeling.py", line 727, in forward
    extended_attention_mask = extended_attention_mask.to(dtype=next(self.parameters()).dtype) # fp16 compatibility
StopIteration

With one GPU the code runs flawlessly, but with 2 GPU's it doesn't run.

Please let me know if you need additional information.

TypeError: 'bool' object is not subscriptable

Greetings! I am facing the following issue while trying to set up the explainer:
TypeError: 'bool' object is not subscriptable

Here is my BERT model:

BertForSequenceClassification(
(bert): BertModel(
(embeddings): BertEmbeddings(
(word_embeddings): Embedding(30522, 768, padding_idx=0)
(position_embeddings): Embedding(512, 768)
(token_type_embeddings): Embedding(2, 768)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(encoder): BertEncoder(
(layer): ModuleList(
(0): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(1): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(2): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(3): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(4): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(5): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(6): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(7): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(8): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(9): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(10): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(11): BertLayer(
(attention): BertAttention(
(self): BertSelfAttention(
(query): Linear(in_features=768, out_features=768, bias=True)
(key): Linear(in_features=768, out_features=768, bias=True)
(value): Linear(in_features=768, out_features=768, bias=True)
(dropout): Dropout(p=0.1, inplace=False)
)
(output): BertSelfOutput(
(dense): Linear(in_features=768, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
(intermediate): BertIntermediate(
(dense): Linear(in_features=768, out_features=3072, bias=True)
)
(output): BertOutput(
(dense): Linear(in_features=3072, out_features=768, bias=True)
(LayerNorm): LayerNorm((768,), eps=1e-12, elementwise_affine=True)
(dropout): Dropout(p=0.1, inplace=False)
)
)
)
)
(pooler): BertPooler(
(dense): Linear(in_features=768, out_features=768, bias=True)
(activation): Tanh()
)
)
(dropout): Dropout(p=0.1, inplace=False)
(classifier): Linear(in_features=768, out_features=6, bias=True)
)

Here is the code:

interpreter_unified = UnifiedInformationExplainer(model=model,
train_dataset=df.loc[X_train]['Sentence'],
device=device,
target_layer=14,
classes=possible_labels)

text = df.loc[X_val]['Sentence'][90]
true_label = df.loc[X_val]['Category'][90]
predicted_label = list(label_dict.keys())[list(label_dict.values()).index(np.argmax(predictions[0]))]

print(text)
print(true_label, predicted_label)

And this is the line that fails:
explanation_unified = interpreter_unified.explain_local(text, true_label)

TypeError Traceback (most recent call last)
in
----> 1 explanation_unified = interpreter_unified.explain_local(text, true_label)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/interpret_text/experimental/unified_information.py in explain_local(self, X, y, name, num_iteration)
117 )
118 regularization = self._calculate_regularization(
--> 119 training_embeddings, self.model
120 ).tolist()
121 self.regular = nn.Parameter(

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/interpret_text/experimental/unified_information.py in _calculate_regularization(self, sampled_x, model, reduced_axes)
169 x = x.to(self.device)
170
--> 171 s = self.Phi(x)
172 if reduced_axes is not None:
173 for axis in reduced_axes:

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/interpret_text/experimental/unified_information.py in Phi(x)
272 classifier = self.model.classifier
273 return classifier(
--> 274 pooler(encoder(hidden_states, attention_mask, False)[-1])
275 )[0]
276 else:

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/torch/nn/modules/module.py in call(self, *input, **kwargs)
530 result = self._slow_forward(*input, **kwargs)
531 else:
--> 532 result = self.forward(*input, **kwargs)
533 for hook in self._forward_hooks.values():
534 hook_result = hook(self, input, result)

/anaconda/envs/azureml_py36/lib/python3.6/site-packages/transformers/modeling_bert.py in forward(self, hidden_states, attention_mask, head_mask, encoder_hidden_states, encoder_attention_mask, output_attentions, output_hidden_states)
434 outputs = (hidden_states,)
435 if self.output_hidden_states:
--> 436 outputs = outputs + (all_hidden_states,)
437 if self.output_attentions:
438 outputs = outputs + (all_attentions,)

TypeError: 'bool' object is not subscriptable

Add dependency on nlp_utils from nlp-recipes

This issue will remove duplicated "utils_bert" and other model code that is copied over from utils_nlp.

Tasks:

  1. identify duplicate utils_nlp/models code
  2. add pip install nlp_recipes to setup
  3. remove duplicated utils related to bert model

Found conflicts! - when creating the conda environment

At the step which prepares the environment to include all the necessary packages and conda files (Python 3.8.5 and Anaconda 3), and specifically at this command:

conda env create -n interpret_cpu --file=interpret_cpu.yaml
it fails to solve the environment and returns with the following error:

Found conflicts! Looking for incompatible packages.

Then it looks for these packages, and then it throws a list of incompatibilities.

When last time I worked with this repo, I worked with Python 3.7, but now I couldn't make it work with that version either. I've attached the yaml file as .txt, and another file with the error message I received.

error.txt
interpret_cpu.txt

Thank you in advance!

Issue with text_classification_classical_text_explainer.ipynb

When executing the following cell:
classifier, best_params = explainer.fit(X_train, y_train)

It results with the following error:
ValueError: empty vocabulary; perhaps the documents only contain stop words

Using the same data set as in the example notebook - haven't changed anything in the code.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.