@@ -29,17 +29,20 @@ struct NoiseAugmentation{A<:AbstractXAIMethod,D<:Sampleable,R<:AbstractRNG} <:
29
29
n:: Int
30
30
distribution:: D
31
31
rng:: R
32
+ show_progress:: Bool
32
33
33
34
function NoiseAugmentation (
34
- analyzer:: A , n:: Int , distribution:: D , rng:: R = GLOBAL_RNG
35
+ analyzer:: A , n:: Int , distribution:: D , rng:: R = GLOBAL_RNG, show_progress = true
35
36
) where {A<: AbstractXAIMethod ,D<: Sampleable ,R<: AbstractRNG }
36
37
n < 1 && throw (ArgumentError (" Number of samples `n` needs to be larger than zero." ))
37
- return new {A,D,R} (analyzer, n, distribution, rng)
38
+ return new {A,D,R} (analyzer, n, distribution, rng, show_progress )
38
39
end
39
40
end
40
- function NoiseAugmentation (analyzer, n:: Int , std:: T = 1.0f0 , rng= GLOBAL_RNG) where {T<: Real }
41
+ function NoiseAugmentation (
42
+ analyzer, n:: Int , std:: T = 1.0f0 , rng= GLOBAL_RNG, show_progress= true
43
+ ) where {T<: Real }
41
44
distribution = Normal (zero (T), std^ 2 )
42
- return NoiseAugmentation (analyzer, n, distribution, rng)
45
+ return NoiseAugmentation (analyzer, n, distribution, rng, show_progress )
43
46
end
44
47
45
48
function call_analyzer (input, aug:: NoiseAugmentation , ns:: AbstractOutputSelector ; kwargs... )
@@ -48,17 +51,20 @@ function call_analyzer(input, aug::NoiseAugmentation, ns::AbstractOutputSelector
48
51
output_indices = ns (output)
49
52
output_selector = AugmentationSelector (output_indices)
50
53
54
+ p = Progress (aug. n; desc= " Sampling NoiseAugmentation..." , showspeed= aug. show_progress)
51
55
# First augmentation
52
56
input_aug = similar (input)
53
57
input_aug = sample_noise! (input_aug, input, aug)
54
58
expl_aug = aug. analyzer (input_aug, output_selector)
55
59
sum_val = expl_aug. val
60
+ next! (p)
56
61
57
62
# Further augmentations
58
63
for _ in 2 : (aug. n)
59
64
input_aug = sample_noise! (input_aug, input, aug)
60
65
expl_aug = aug. analyzer (input_aug, output_selector)
61
66
sum_val += expl_aug. val
67
+ next! (p)
62
68
end
63
69
64
70
# Average explanation
0 commit comments