Skip to main content

Testing with Concept Activation Vectors code

Project description

Interpretability Beyond Feature Attribution: Quantitative Testing with Concept Activation Vectors (TCAV) [ICML 2018]

Been Kim, Martin Wattenberg, Justin Gilmer, Carrie Cai, James Wexler, Fernanda Viegas, Rory Sayres

ICML Paper: https://arxiv.org/abs/1711.11279

What is TCAV?

Testing with Concept Activation Vectors (TCAV) is a new interpretability method to understand what signals your neural networks models uses for prediction.

What's special about TCAV compared to other methods?

Typical interpretability methods show importance weights in each input feature (e.g, pixel). TCAV instead shows importance of high level concepts (e.g., color, gender, race) for a prediction class - this is how humans communicate!

Typical interpretability methods require you to have one particular image that you are interested in understanding. TCAV gives an explanation that is generally true for a class of interest, beyond one image (global explanation).

For example, for a given class, we can show how much race or gender was important for classifications in InceptionV3. Even though neither race nor gender labels were part of the training input!

Cool, where do these concepts come from?

TCAV learns concepts from examples. For instance, TCAV needs a couple of examples of female, and something not female to learn a "gender" concept. We have tested a variety of concepts: color, gender, race, textures and many others.

Why use high level concepts instead of input features?

Humans think and communicate using concepts, and not using numbers (e.g., weights to each feature). When there are lots of numbers to combine and reason about (many features), it becomes harder and harder for humans to make sense of the information they are accounting for. TCAV instead delivers explanations in the way humans communicate to each other.

The consumer of the explanation may not know machine learning too well. Can they understand the explanation?

Yes. TCAV is designed to make sense to everyone - as long as they can understand the high level concept!

Sounds good. Do I need to change my network to use TCAV?

No. You don't need to change or retrain your network to use TCAV.

Installation

Tensorflow must be installed to use TCAV. But it isn't included in the TCAV pip package install_requires as a user may wish to use it with either the tensorflow or tensorflow-gpu package. So please pip install tensorflow or tensorflow-gpu as well as the tcav package.

pip install tcav

Requirements

See requirements.txt for a list of python dependencies used in testing TCAV. These will all be installed during pip installation of tcav with the exception of tensorflow, as mentioned above.

How to use TCAV

See Run TCAV.ipynb for step by step guide, after pip installing the tcav package.

mytcav = tcav.TCAV(sess,
                   target,
                   concepts,
                   bottlenecks,
                   act_gen,
                   alphas,
                   cav_dir=cav_dir,
                   num_random_exp=2)

results = mytcav.run()

How to run unit tests

Run these commands from the parent of this tcav directory: python -m tcav.cav_test

python -m tcav.tcav_test

python -m tcav.utils_test

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distributions

tcav-0.1-py3-none-any.whl (30.9 kB view details)

Uploaded Python 3

tcav-0.1-py2-none-any.whl (30.9 kB view details)

Uploaded Python 2

File details

Details for the file tcav-0.1-py3-none-any.whl.

File metadata

  • Download URL: tcav-0.1-py3-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for tcav-0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 a334356379e37180e0740d479a3641021f622ac20e88c969dbb630621eade1ec
MD5 a8b167a422f1ad0cfb65aa543e1ba5a2
BLAKE2b-256 27ad4cff40c6eb8f069ce103697d667dcf3926604b4d47cafc2314d253aebe57

See more details on using hashes here.

File details

Details for the file tcav-0.1-py2-none-any.whl.

File metadata

  • Download URL: tcav-0.1-py2-none-any.whl
  • Upload date:
  • Size: 30.9 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.13.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.0.1 requests-toolbelt/0.9.1 tqdm/4.32.1 CPython/2.7.16

File hashes

Hashes for tcav-0.1-py2-none-any.whl
Algorithm Hash digest
SHA256 47f171a88590e72881445749e05abed6cdaa6c965905e3b1b288b92203b931c2
MD5 4e88ed81be121b44b7629f7d835b342d
BLAKE2b-256 2246b5f6408b22403e6ddbd8411e9bd0237c2a77572d6d87078527446e4c19fa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page