We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 8d2e009 commit 8514fa5Copy full SHA for 8514fa5
test/testsuite/spectral.jl
@@ -110,9 +110,19 @@ function spectral_testsuite(Backend)
110
spec = spectrogram(x;
111
n_fft=1024, hop_length=128, window,
112
center=true, normalized=false)
113
-
114
@test abs.(y).^2 ≈ spec
115
+ # Gradient with `0`s in spectrogram.
116
+ # We add small ϵ to spectrogram before computing power
117
+ # to prevent `NaN` in gradient due to `abs(0)`.
118
+ x = device(ones(Float32, 1024))
119
+ g = Zygote.gradient(x) do x
120
+ sum(spectrogram(x;
121
+ n_fft=1024, hop_length=128, window,
122
+ center=true, normalized=false))
123
+ end
124
+ @test !any(isnan.(g[1]))
125
+
126
# Batched.
127
x = device(rand(Float32, 1024, 3))
128
0 commit comments