Git Product home page Git Product logo

explainableai.jl's Issues

Reduce allocations in LRP methods

  • Instead of having rules modify layer parameters, avoid allocations by implementing modified forward calls that can be diff'ed.
  • Pre-allocate buffers
    • for activations on forward-pass
    • for relevances on backward-pass
  • For analysis of multiple output neurons, only run forward-pass once

This should speed things up a lot!

Add LRP support for nested Chains

This will be the first step towards #10 by allowing nested model structures.

This requires the following changes:

  • new internal representation of rules, e.g. via LRPRulesChain / LRPRulesParallel [Edit: now called ChainTuple and ParallelTuple] to support graphs
  • treat chains the same way as layers by adding lrp!(Rₖ, r::AbstractLRPRule, c::Chain, aₖ, Rₖ₊₁), which can be called recursively. This will require a different approach to pre-allocating activations and relevances than the one currently used in the call to the analyzer.
  • Composite might require a refactoring
  • Update lrp/show.jl

Add model canonization

Add function canonize(model) which merges BatchNorm layers into Dense and Conv layers with linear activation functions.

Test GPU support

GPU support is currently untested. In theory, GPU tests could be run on CI using the JuliaGPU Buildkite CI.

Locally, a first test of GPU support can be run by modifying the readme example to cast input to a GPU array.
It should be possible to run the following code in a fresh temp-environment:

using CUDA
using ExplainableAI
using Flux
using MLDatasets
using Downloads: download
using BSON: @load

model_url = "https://github.com/adrhill/ExplainableAI.jl/raw/master/docs/src/model.bson"
path = joinpath(@__DIR__, "model.bson")
!isfile(path) && download(model_url, path)
@load "model.bson" model

model = strip_softmax(model)
x, _ = MNIST.testdata(Float32, 10)
input = reshape(x, 28, 28, 1, :)

input_gpu = gpu(input) # cast input to GPU array
analyzer = LRP(model)
expl = analyze(input_gpu, analyzer)

Remove ImageNet preprocessing code

This should be handled via external packages DataAugmentations.jl.

  • document preprocessing with external packages

Since this is a breaking change, it should be implemented before a 1.0 release.

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

LRP rule coverage for Flux layers

This issue keeps track of which Flux layers in the model reference got LRP implementations.


Basic layers

  • Dense
  • flatten

Convolution

  • Conv
  • DepthwiseConv
  • ConvTranspose
  • CrossCor

Pooling layers

  • AdaptiveMaxPool
  • MaxPool
  • GlobalMaxPool
  • AdaptiveMeanPool
  • MeanPool
  • GlobalMeanPool

General purpose

  • Maxout
  • SkipConnection
  • Chain #119
  • Parallel #10
  • Bilinear
  • Diagonal
  • Embedding

Normalisation & regularisation

  • normalise
  • BatchNorm #129
  • dropout
  • Dropout
  • AlphaDropout
  • LayerNorm
  • InstanceNorm
  • GroupNorm

Upsampling layers

  • Upsample
  • PixelShuffle

Recurrent layers

  • RNN
  • LSTM
  • GRU
  • Recur

Add model checks for LRP

  • Check model for non-ReLU-like activations and unknown layers.
  • Display a summary as to why checks failed if they do, as well as references to the docs on how to fix these issues.
  • Make checks skip-able through LRP kwarg skip_checks=true.

The goal should be to make ExplainabilityMethods transparent but extendable.

Move LRP into separate package

This would remove the dependency on Flux and make the package lighter for users that don't require LRP.

Since this requires a breaking release, this is a milestone for a future 1.0 release.

Refactor results struct

Update field names.
The field layerwise_relevances of the Explanation struct is too specific to LRP.
An extras field of type Union{Nothing, Dict} would be more flexible.

Add `ZPlusRule`

Could be implemented as the one-liner ZPlusRule() = AlphaBetaRule(1.0f0, 0.0f0),
but a large part of the computation could be skipped since β=0.

Fix randomness in gradients

Zygote's gradient appears to be non-deterministic on Metalhead's VGG19:

julia> a = gradient((in) -> model(in)[1], imgp)[1];

julia> b = gradient((in) -> model(in)[1], imgp)[1];

julia> isapprox(a, b; atol=1e-3)
false

julia> isapprox(a, b; atol=1e-2)
true

Check whether this is due to Dropout layers or Zygote.

Add default composites

  • Add presets similar to those in Zennit, e.g.:
    • EpsilonGammaBox
    • EpsilonPlus
    • EpsilonAlpha2Beta1
    • EpsilonPlusFlat
    • EpsilonAlpha2Beta1Flat
  • Update README with examples from presets

Regression tests of all methods on VGG19

Metalhead disabled pretrained weights in 0.6.0 due to model inaccuracies.
These can technically still be loaded while they are being fixed:

model = VGG19()
Flux.loadparams!(model.layers, weights("vgg19"))

However, the VGG19 weights are a 548 MB download every time CI is run. It might therefore be more reasonable to use a smaller model. Currently, MetalheadWeights contains (in ascending size):

  • SqueezeNet (5 MB) -> requires Parallel for "fire" modules
  • GoogLeNet (27 MB) -> requires Parallel
  • Densenet121 (31 MB) -> requires SkipConnection
  • ResNet-50 (98 MB) -> requires Parallel, skip_identity
  • VGG-19 (548 MB)

An easy workaround would be to run the methods on randomly initialized parameters (with fixed seed). The explanations w.r.t. to this model should still stay constant.

Add docs

Add doc pages for:

  • Basic example on VGG model
  • Combining LRP rules
  • Custom LRP rules

Also:

  • Add images to readme

Update documentation for `v0.6.0` release

Currently, the following things can be improved or are missing documentation:

  • input augmentations: NoiseAugmentation, InterpolationAugmentation
  • usage of LayerMap and show_layer_indices introduced in #131
  • LRP keyword flatten and performance benefits
  • LRP model canonization
  • Update section "How it works internally" for #119
  • Update "Model checks for humans" for #119
  • Use DocumenterCitations.jl
  • #64

Support input batches

This should return a Vector{Explanation}, which should also be supported by heatmap.

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.