You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49-14Lines changed: 49 additions & 14 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -17,36 +17,52 @@ This package supports Julia ≥1.6. To install it, open the Julia REPL and run
17
17
julia> ]add ExplainableAI
18
18
```
19
19
20
-
⚠️ This package is still in early development, expect breaking changes. ⚠️
21
-
22
20
## Example
23
-
Let's use LRP to explain why an MNIST digit gets classified as a 9 using a small pre-trained LeNet5 model.
24
-
If you want to follow along, the model can be found [here][model-bson-url].
21
+
Let's use LRP to explain why an image of a castle gets classified as such using a pre-trained VGG16 model from [Metalhead.jl](https://github.com/FluxML/Metalhead.jl):
22
+
![][castle]
25
23
```julia
26
24
using ExplainableAI
27
25
using Flux
28
-
usingMLDatasets
29
-
usingBSON:@load
26
+
usingMetalhead
27
+
usingFileIO
30
28
31
29
# Load model
32
-
@load"model.bson" model
33
-
model =strip_softmax(model)
30
+
model=VGG(16, pretrain=true).layers
31
+
model =strip_softmax(flatten_chain(model))
34
32
35
33
# Load input
36
-
x, _ =MNIST(Float32, :test)[10]
37
-
input =reshape(x, 28, 28, 1, :) # reshape to WHCN format
34
+
img =load("castle.jpg")
35
+
input =preprocess_imagenet(img)
36
+
input =reshape(input, 224, 224, 3, :) # reshape to WHCN format
We can also get an explanation for the activation of the output neuron corresponding to the "street sign" class by specifying the corresponding output neuron position `920`:
50
+
```julia
51
+
analyze(input, analyzer, 920) # for explanation
52
+
heatmap(input, analyzer, 920) # for heatmap
53
+
```
54
+
Heatmaps for all implemented analyzers are shown in the following table. Red color indicate regions of positive relevance towards the selected class, whereas regions in blue are of negative relevance.
55
+
56
+
|**Analyzer**|**Heatmap for class "castle"**|**Heatmap for class "street sign"**|
The code used to generate these heatmaps can be found [here][asset-code].
50
66
51
67
## Methods
52
68
Currently, the following analyzers are implemented:
@@ -70,6 +86,10 @@ Currently, the following analyzers are implemented:
70
86
One of the design goals of ExplainableAI.jl is extensibility.
71
87
Individual LRP rules [can be composed][docs-composites] and are easily extended by [custom rules][docs-custom-rules].
72
88
89
+
## Video demonstration
90
+
Check out our [JuliaCon 2022 talk][juliacon-url] for a demonstration of the package.
91
+
[![][juliacon-img]][juliacon-url]
92
+
73
93
## Roadmap
74
94
In the future, we would like to include:
75
95
-[PatternNet](https://arxiv.org/abs/1705.05598)
@@ -83,7 +103,21 @@ Contributions are welcome!
83
103
> 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).
0 commit comments