@@ -16,26 +16,25 @@ allowing you to automatically compute heatmaps for vision and language models.
16
16
It also allows you to use input-augmentations from [ ExplainableAI.jl] [ url-explainableai ] .
17
17
18
18
## Interface description
19
- This only requires you to fulfill the following two requirements:
19
+ XAIBase only requires you to fulfill the following two requirements:
20
20
21
- 1 . An XAI method has to be a subtype of ` AbstractXAIMethod `
22
- 2 . An XAI method has to implement the following method:
21
+ 1 . An XAI algorithm has to be a subtype of [ ` AbstractXAIMethod ` ] [ docs-abstractxaimethod ]
22
+ 2 . An XAI algorithm has to implement the following method:
23
23
24
24
``` julia
25
25
(method:: MyMethod )(input, output_selector:: AbstractOutputSelector )
26
26
```
27
27
28
- * The method has to return an [ ` Explanation ` ] [ docs-explanation ]
29
- * The input is expected to have a batch dimensions as its last dimension
30
- * When applied to a batch, the method returns a single [ ` Explanation ` ] [ docs-explanation ] ,
28
+ * the method has to return an [ ` Explanation ` ] [ docs-explanation ]
29
+ * the input is expected to have a batch dimensions as its last dimension
30
+ * when applied to a batch, the method returns a single [ ` Explanation ` ] [ docs-explanation ] ,
31
31
which contains the batched output in the ` val ` field.
32
- * ` AbstractOutputSelector ` s are predefined callable structs
33
- that select a single scalar value from a model's output,
34
- e.g. the maximally activated output of a classifier using [ ` XAIBase.MaxActivationSelector ` ] [ docs-maxactivationselector ]
35
- or a specific output using [ ` XAIBase.IndexSelector ` ] [ docs-indexselector ] .
32
+ * [ ` AbstractOutputSelector ` ] [ docs-abstractoutputselector ]
33
+ are predefined callable structs that select scalar values from a model's output,
34
+ e.g. the maximally activated output of a classifier using [ ` MaxActivationSelector ` ] [ docs-maxactivationselector ] .
36
35
37
36
Refer to the [ ` Explanation ` ] [ docs-explanation ] documentation for a description of the expected fields.
38
- For more information, take a look at [ ` src/XAIBase.jl ` ] ( https://github.com/Julia-XAI/XAIBase.jl/blob/main/src/XAIBase.jl ) .
37
+ For more information, take a look at the [ documentation ] [ docs ] .
39
38
40
39
## Example implementation
41
40
Julia-XAI methods will usually follow the following template:
@@ -50,8 +49,8 @@ function (method::MyMethod)(input, output_selector::AbstractOutputSelector)
50
49
output_selection = output_selector (output)
51
50
52
51
val = ... # your method's implementation
53
- extras = nothing # or some additional information
54
- return Explanation (val, output, output_selection, :MyMethod , :sensitivity , extras)
52
+ extras = nothing # optionally add additional information using a named tuple
53
+ return Explanation (val, output, output_selection, :MyMethod , :attribution , extras)
55
54
end
56
55
```
57
56
69
68
[ docs-extensions ] : https://pkgdocs.julialang.org/v1/creating-packages/#Conditional-loading-of-code-in-packages-(Extensions)
70
69
[ docs ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/
71
70
[ docs-explanation ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/api/#XAIBase.Explanation
71
+ [ docs-abstractxaimethod ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/api/#XAIBase.AbstractXAIMethod
72
+ [ docs-abstractoutputselector ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/api/#XAIBase.AbstractOutputSelector
72
73
[ docs-maxactivationselector ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/api/#XAIBase.MaxActivationSelector
73
74
[ docs-indexselector ] : https://julia-xai.github.io/XAIDocs/XAIBase/stable/api/#XAIBase.IndexSelector
0 commit comments