# -*- coding: utf-8 -*-
from setuptools import setup

package_dir = \
{'': 'src'}

packages = \
['innvestigate',
 'innvestigate.analyzer',
 'innvestigate.analyzer.relevance_based',
 'innvestigate.backend',
 'innvestigate.tools',
 'innvestigate.utils']

package_data = \
{'': ['*']}

install_requires = \
['future>=0.18.2,<0.19.0',
 'matplotlib>=3.5.1,<4.0.0',
 'numpy>=1.22,<2.0',
 'tensorflow>=2.6,<2.11']

setup_kwargs = {
    'name': 'innvestigate',
    'version': '2.0.1',
    'description': "A toolbox to innvestigate neural networks' predictions.",
    'long_description': '# [iNNvestigate neural networks!](https://github.com/albermax/innvestigate) [![Tweet](https://img.shields.io/twitter/url/http/shields.io.svg?style=social)](https://twitter.com/intent/tweet?text=iNNvestigate%20neural%20networks!&url=https://github.com/albermax/innvestigate&hashtags=iNNvestigate,artificialintelligence,machinelearning,deeplearning,datascience)\n\n[![Documentation](https://img.shields.io/badge/Documentation-stable-blue.svg)](https://innvestigate.readthedocs.io/en/latest/)\n[![Build Status](https://github.com/albermax/innvestigate/actions/workflows/ci.yml/badge.svg)](https://github.com/albermax/innvestigate/actions/workflows/ci.yml)\n\n[![PyPI package version](https://img.shields.io/pypi/v/innvestigate)](https://pypi.org/project/innvestigate/)\n[![GitHub package version](https://img.shields.io/github/v/tag/albermax/innvestigate)](https://github.com/albermax/innvestigate/tags)\n[![License: BSD-2](https://img.shields.io/badge/License-BSD--2-purple.svg)](https://github.com/albermax/innvestigate/blob/master/LICENSE)\n[![Black](https://img.shields.io/badge/code_style-black-black.svg)](https://github.com/psf/black)\n\n[![Python](https://img.shields.io/pypi/pyversions/innvestigate.svg)](https://badge.fury.io/py/innvestigate)\n[![TensorFlow package version](https://img.shields.io/badge/TensorFlow-2.6_--_2.10-orange.svg)](https://github.com/albermax/innvestigate)\n\n![Different explanation methods on ImageNet.](https://github.com/albermax/innvestigate/raw/master/examples/images/analysis_grid.png)\n\n## Table of contents\n\n* [Introduction](#introduction)\n* [Installation](#installation)\n* [Usage and Examples](#usage-and-examples)\n* [More documentation](#more-documentation)\n* [Contributing](#contributing)\n* [Releases](#releases)\n\n## Introduction\n\nIn the recent years neural networks furthered the state of the art in many domains like, e.g., object detection and speech recognition.\nDespite the success neural networks are typically still treated as black boxes. Their internal workings are not fully understood and the basis for their predictions is unclear.\nIn the attempt to understand neural networks better several methods were proposed, e.g., Saliency, Deconvnet, GuidedBackprop, SmoothGrad, IntergratedGradients, LRP, PatternNet\\&-Attribution.\nDue to the lack of a reference implementations comparing them is a major effort.\nThis library addresses this by providing a common interface and out-of-the-box implementation for many analysis methods.\nOur goal is to make analyzing neural networks\' predictions easy!\n\n\n### If you use this code please star the repository and cite the following paper:\n\n[Alber, M., Lapuschkin, S., Seegerer, P., Hägele, M., Schütt, K. T., Montavon, G., Samek, W., Müller, K. R., Dähne, S., & Kindermans, P. J. (2019). **iNNvestigate neural networks!** Journal of Machine Learning Research, 20.](https://jmlr.org/papers/v20/18-540.html)\n  ```\n  @article{JMLR:v20:18-540,\n  author  = {Maximilian Alber and Sebastian Lapuschkin and Philipp Seegerer and Miriam H{{\\"a}}gele and Kristof T. Sch{{\\"u}}tt and Gr{{\\\'e}}goire Montavon and Wojciech Samek and Klaus-Robert M{{\\"u}}ller and Sven D{{\\"a}}hne and Pieter-Jan Kindermans},\n  title   = {iNNvestigate Neural Networks!},\n  journal = {Journal of Machine Learning Research},\n  year    = {2019},\n  volume  = {20},\n  number  = {93},\n  pages   = {1-8},\n  url     = {http://jmlr.org/papers/v20/18-540.html}\n  }\n  ```\n\n## Installation\n\niNNvestigate is based on Keras and TensorFlow 2 and can be installed with the following commands:\n\n```bash\npip install innvestigate\n```\n\n**Please note that iNNvestigate currently requires disabling TF2\'s eager execution.**\n\nTo use the example scripts and notebooks one additionally needs to install the package matplotlib:\n\n```bash\npip install matplotlib\n```\n\nThe library\'s tests can be executed via `pytest`. The easiest way to do reproducible development on iNNvestigate is to install all dev dependencies via [Poetry](https://python-poetry.org):\n```bash\ngit clone https://github.com/albermax/innvestigate.git\ncd innvestigate\n\npoetry install\npoetry run pytest\n```\n\n## Usage and Examples\n\nThe iNNvestigate library contains implementations for the following methods:\n\n* *function:*\n  * **gradient:** The gradient of the output neuron with respect to the input.\n  * **smoothgrad:** [SmoothGrad](https://arxiv.org/abs/1706.03825) averages the gradient over number of inputs with added noise.\n* *signal:*\n  * **deconvnet:** [DeConvNet](https://arxiv.org/abs/1311.2901) applies a ReLU in the gradient computation instead of the gradient of a ReLU.\n  * **guided:** [Guided BackProp](https://arxiv.org/abs/1412.6806) applies a ReLU in the gradient computation additionally to the gradient of a ReLU.\n  * **pattern.net:** [PatternNet](https://arxiv.org/abs/1705.05598) estimates the input signal of the output neuron. (*Note: not available in iNNvestigate 2.0*)\n* *attribution:*\n  * **input_t_gradient:** Input \\* Gradient\n  * **deep_taylor[.bounded]:** [DeepTaylor](https://www.sciencedirect.com/science/article/pii/S0031320316303582?via%3Dihub) computes for each neuron a root point, that is close to the input, but which\'s output value is 0, and uses this difference to estimate the attribution of each neuron recursively.\n  * **lrp.\\*:** [LRP](http://journals.plos.org/plosone/article?id=10.1371/journal.pone.0130140) attributes recursively to each neuron\'s input relevance proportional to its contribution of the neuron output.\n  * **integrated_gradients:** [IntegratedGradients](https://arxiv.org/abs/1703.01365) integrates the gradient along a path from the input to a reference.\n* *miscellaneous:*\n  * **input:** Returns the input.\n  * **random:** Returns random Gaussian noise.\n\n**The intention behind iNNvestigate is to make it easy to use analysis methods, but it is not to explain the underlying concepts and assumptions. Please, read the according publication(s) when using a certain method and when publishing please cite the according paper(s) (as well as the [iNNvestigate paper](https://arxiv.org/abs/1808.04260)). Thank you!**\n\nAll the available methods have in common that they try to analyze the output of a specific neuron with respect to input to the neural network.\nTypically one analyses the neuron with the largest activation in the output layer.\nFor example, given a Keras model, one can create a \'gradient\' analyzer:\n\n```python\nimport tensorflow as tf\nimport innvestigate\ntf.compat.v1.disable_eager_execution()\n\nmodel = create_keras_model()\n\nanalyzer = innvestigate.create_analyzer("gradient", model)\n```\n\nand analyze the influence of the neural network\'s input on the output neuron by:\n\n```python\nanalysis = analyzer.analyze(inputs)\n```\n\nTo analyze a neuron with the index i, one can use the following scheme:\n\n```python\nanalyzer = innvestigate.create_analyzer("gradient",\n                                        model,\n\t\t\t\t\tneuron_selection_mode="index")\nanalysis = analyzer.analyze(inputs, i)\n```\n\nLet\'s look at an example ([code](https://github.com/albermax/innvestigate/blob/master/examples/readme_code_snippet.py)) with VGG16 and this image:\n\n![Input image.](https://github.com/albermax/innvestigate/raw/master/examples/images/readme_example_input.png)\n\n\n```python\nimport tensorflow as tf\nimport tensorflow.keras.applications.vgg16 as vgg16\ntf.compat.v1.disable_eager_execution()\n\nimport innvestigate\n\n# Get model\nmodel, preprocess = vgg16.VGG16(), vgg16.preprocess_input\n# Strip softmax layer\nmodel = innvestigate.model_wo_softmax(model)\n\n# Create analyzer\nanalyzer = innvestigate.create_analyzer("deep_taylor", model)\n\n# Add batch axis and preprocess\nx = preprocess(image[None])\n# Apply analyzer w.r.t. maximum activated output-neuron\na = analyzer.analyze(x)\n\n# Aggregate along color channels and normalize to [-1, 1]\na = a.sum(axis=np.argmax(np.asarray(a.shape) == 3))\na /= np.max(np.abs(a))\n# Plot\nplt.imshow(a[0], cmap="seismic", clim=(-1, 1))\n```\n\n![Analysis image.](https://github.com/albermax/innvestigate/raw/master/examples/images/readme_example_analysis.png)\n\n### Tutorials\n\nIn the directory [examples](https://github.com/albermax/innvestigate/blob/master/examples/) one can find different examples as Python scripts and as Jupyter notebooks:\n\n* **[Introduction to iNNvestigate](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/introduction.ipynb):** shows how to use **iNNvestigate**.\n* **[Comparing methods on MNIST](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/mnist_compare_methods.ipynb):** shows how to train and compare analyzers on MNIST.\n* **[Comparing output neurons on MNIST](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/mnist_neuron_selection.ipynb):** shows how to analyze the prediction of different classes on MNIST.\n* **[Comparing methods on ImageNet](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/imagenet_compare_methods.ipynb):** shows how to compare analyzers on ImageNet.\n* **[Comparing networks on ImageNet](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/imagenet_compare_networks.ipynb):** shows how to compare analyzes for different networks on ImageNet.\n* **[Sentiment Analysis](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/sentiment_analysis.ipynb)**.\n* **[Development with iNNvestigate](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/introduction_development.ipynb):** shows how to develop with **iNNvestigate**.\n* **[Perturbation Analysis](https://github.com/albermax/innvestigate/blob/master/examples/notebooks/mnist_perturbation.ipynb)**.\n---\n\n**To use the ImageNet examples please download the example images first ([script](https://github.com/albermax/innvestigate/blob/master/examples/images/wget_imagenet_2011_samples.sh)).**\n\n## More documentation\n\n... can be found here:\n\n* Alber, M., Lapuschkin, S., Seegerer, P., Hägele, M., Schütt, K. T., Montavon, G., Samek, W., Müller, K. R., Dähne, S., & Kindermans, P. J. (2019). INNvestigate neural networks! Journal of Machine Learning Research, 20.](https://jmlr.org/papers/v20/18-540.html)\n  ```\n  @article{JMLR:v20:18-540,\n  author  = {Maximilian Alber and Sebastian Lapuschkin and Philipp Seegerer and Miriam H{{\\"a}}gele and Kristof T. Sch{{\\"u}}tt and Gr{{\\\'e}}goire Montavon and Wojciech Samek and Klaus-Robert M{{\\"u}}ller and Sven D{{\\"a}}hne and Pieter-Jan Kindermans},\n  title   = {iNNvestigate Neural Networks!},\n  journal = {Journal of Machine Learning Research},\n  year    = {2019},\n  volume  = {20},\n  number  = {93},\n  pages   = {1-8},\n  url     = {http://jmlr.org/papers/v20/18-540.html}\n  }\n  ```\n* [https://innvestigate.readthedocs.io/en/latest/](https://innvestigate.readthedocs.io/en/latest/)\n\n## Contributing\n\nIf you would like to contribute or add your analysis method \nplease open an issue or submit a pull request.\n\n## Releases\n\n[Can be found here.](https://github.com/albermax/innvestigate/blob/master/VERSION.md)\n\n\n## Acknowledgements\n\n> Adrian Hill acknowledges support by the Federal Ministry of Education and Research (BMBF) for the Berlin Institute for the Foundations of Learning and Data (BIFOLD) (01IS18037A).',
    'author': 'Maxmilian Alber',
    'author_email': 'workDoTalberDoTmaximilian@gmail.com',
    'maintainer': 'Adrian Hill',
    'maintainer_email': 'hill@tu-berlin.de',
    'url': 'https://github.com/albermax/innvestigate',
    'package_dir': package_dir,
    'packages': packages,
    'package_data': package_data,
    'install_requires': install_requires,
    'python_requires': '>=3.8,<3.11',
}


setup(**setup_kwargs)
