9
9
(s:: AugmentationSelector )(out) = s. indices
10
10
11
11
"""
12
- NoiseAugmentation(analyzer, n)
13
- NoiseAugmentation(analyzer, n, std::Real)
14
- NoiseAugmentation(analyzer, n, distribution::Sampleable)
12
+ NoiseAugmentation(analyzer, n, [std::Real, rng])
13
+ NoiseAugmentation(analyzer, n, [distribution::Sampleable, rng])
15
14
16
15
A wrapper around analyzers that augments the input with `n` samples of additive noise sampled from a scalar `distribution`.
17
16
This input augmentation is then averaged to return an `Explanation`.
17
+ Defaults to the normal distribution with zero mean and `std=1.0f0`.
18
18
19
- Defaults to the normal distribution `Normal(0, std^2)` with `std=1.0f0`.
20
19
For optimal results, $REF_SMILKOV_SMOOTHGRAD recommends setting `std` between 10% and 20% of the input range of each sample,
21
20
e.g. `std = 0.1 * (maximum(input) - minimum(input))`.
22
21
@@ -32,17 +31,14 @@ struct NoiseAugmentation{A<:AbstractXAIMethod,D<:Sampleable,R<:AbstractRNG} <:
32
31
rng:: R
33
32
34
33
function NoiseAugmentation (
35
- analyzer:: A , n:: Int , distribution:: D , rng:: R
34
+ analyzer:: A , n:: Int , distribution:: D , rng:: R = GLOBAL_RNG
36
35
) where {A<: AbstractXAIMethod ,D<: Sampleable ,R<: AbstractRNG }
37
- n < 2 &&
38
- throw (ArgumentError (" Number of noise samples `n` needs to be larger than one." ))
36
+ n < 1 && throw (ArgumentError (" Number of samples `n` needs to be larger than zero." ))
39
37
return new {A,D,R} (analyzer, n, distribution, rng)
40
38
end
41
39
end
42
- function NoiseAugmentation (analyzer, n, std:: T = 1.0f0 , rng= GLOBAL_RNG) where {T<: Real }
43
- return NoiseAugmentation (analyzer, n, Normal (zero (T), std^ 2 ), rng)
44
- end
45
- function NoiseAugmentation (analyzer, n, distribution:: Sampleable , rng= GLOBAL_RNG)
40
+ function NoiseAugmentation (analyzer, n:: Int , std:: T = 1.0f0 , rng= GLOBAL_RNG) where {T<: Real }
41
+ distribution = Normal (zero (T), std^ 2 )
46
42
return NoiseAugmentation (analyzer, n, distribution, rng)
47
43
end
48
44
0 commit comments