99(s:: AugmentationSelector )(out) = s. indices
1010
1111"""
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])
1514
1615A wrapper around analyzers that augments the input with `n` samples of additive noise sampled from a scalar `distribution`.
1716This input augmentation is then averaged to return an `Explanation`.
17+ Defaults to the normal distribution with zero mean and `std=1.0f0`.
1818
19- Defaults to the normal distribution `Normal(0, std^2)` with `std=1.0f0`.
2019For optimal results, $REF_SMILKOV_SMOOTHGRAD recommends setting `std` between 10% and 20% of the input range of each sample,
2120e.g. `std = 0.1 * (maximum(input) - minimum(input))`.
2221
@@ -32,17 +31,14 @@ struct NoiseAugmentation{A<:AbstractXAIMethod,D<:Sampleable,R<:AbstractRNG} <:
3231 rng:: R
3332
3433 function NoiseAugmentation (
35- analyzer:: A , n:: Int , distribution:: D , rng:: R
34+ analyzer:: A , n:: Int , distribution:: D , rng:: R = GLOBAL_RNG
3635 ) 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." ))
3937 return new {A,D,R} (analyzer, n, distribution, rng)
4038 end
4139end
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 )
4642 return NoiseAugmentation (analyzer, n, distribution, rng)
4743end
4844
0 commit comments