Skip to content

Commit 35b8632

Browse files
committed
Uncomment asserts
1 parent e00f79d commit 35b8632

File tree

3 files changed

+10
-17
lines changed

3 files changed

+10
-17
lines changed

tutorials/01-gaussian-mixture-model/index.qmd

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -142,8 +142,7 @@ let
142142
# μ[1] and μ[2] can switch places, so we sort the values first.
143143
chain = Array(chains[:, ["μ[1]", "μ[2]"], i])
144144
μ_mean = vec(mean(chain; dims=1))
145-
# TODO: https://github.com/TuringLang/docs/issues/533
146-
# @assert isapprox(sort(μ_mean), μ; rtol=0.1) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
145+
@assert isapprox(sort(μ_mean), μ; rtol=0.1) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
147146
end
148147
end
149148
```
@@ -208,8 +207,7 @@ let
208207
# μ[1] and μ[2] can no longer switch places. Check that they've found the mean
209208
chain = Array(chains[:, ["μ[1]", "μ[2]"], i])
210209
μ_mean = vec(mean(chain; dims=1))
211-
# TODO: https://github.com/TuringLang/docs/issues/533
212-
# @assert isapprox(sort(μ_mean), μ; rtol=0.4) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
210+
@assert isapprox(sort(μ_mean), μ; rtol=0.4) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
213211
end
214212
end
215213
```
@@ -349,8 +347,7 @@ let
349347
# μ[1] and μ[2] can no longer switch places. Check that they've found the mean
350348
chain = Array(chains[:, ["μ[1]", "μ[2]"], i])
351349
μ_mean = vec(mean(chain; dims=1))
352-
# TODO: https://github.com/TuringLang/docs/issues/533
353-
# @assert isapprox(sort(μ_mean), μ; rtol=0.4) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
350+
@assert isapprox(sort(μ_mean), μ; rtol=0.4) "Difference between estimated mean of μ ($(sort(μ_mean))) and data-generating μ ($μ) unexpectedly large!"
354351
end
355352
end
356353
```

tutorials/09-variational-inference/index.qmd

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,8 @@ var(x), mean(x)
155155
#| echo: false
156156
let
157157
v, m = (mean(rand(q, 2000); dims=2)...,)
158-
# TODO: Fix these as they randomly fail https://github.com/TuringLang/docs/issues/533
159-
# @assert isapprox(v, 1.022; atol=0.1) "Mean of s (VI posterior, 1000 samples): $v"
160-
# @assert isapprox(m, -0.027; atol=0.03) "Mean of m (VI posterior, 1000 samples): $m"
158+
@assert isapprox(v, 1.022; atol=0.1) "Mean of s (VI posterior, 1000 samples): $v"
159+
@assert isapprox(m, -0.027; atol=0.03) "Mean of m (VI posterior, 1000 samples): $m"
161160
end
162161
```
163162

tutorials/11-probabilistic-pca/index.qmd

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -246,13 +246,10 @@ heatmap(
246246
We can quantitatively check the absolute magnitudes of the column average of the gap between `mat_exp` and `mat_rec`:
247247

248248
```{julia}
249-
#| echo: false
250-
# let
251-
# diff_matrix = mat_exp .- mat_rec
252-
# @assert abs(mean(diff_matrix[:, 4])) <= 0.5 #0.327
253-
# @assert abs(mean(diff_matrix[:, 5])) <= 0.5 #0.390
254-
# @assert abs(mean(diff_matrix[:, 6])) <= 0.5 #0.326
255-
# end
249+
diff_matrix = mat_exp .- mat_rec
250+
for col in 4:6
251+
@assert abs(mean(diff_matrix[:, col])) <= 0.5
252+
end
256253
```
257254

258255
We observe that, using posterior mean, the recovered data matrix `mat_rec` has values align with the original data matrix - particularly the same pattern in the first and last 3 gene features are captured, which implies the inference and p-PCA decomposition are successful.
@@ -383,4 +380,4 @@ It can also thought as a matrix factorisation method, in which $\mathbf{X}=(\mat
383380
[^2]: Probabilistic PCA by TensorFlow, "https://www.tensorflow.org/probability/examples/Probabilistic_PCA".
384381
[^3]: Gareth M. James, Daniela Witten, Trevor Hastie, Robert Tibshirani, *An Introduction to Statistical Learning*, Springer, 2013.
385382
[^4]: David Wipf, Srikantan Nagarajan, *A New View of Automatic Relevance Determination*, NIPS 2007.
386-
[^5]: Christopher Bishop, *Pattern Recognition and Machine Learning*, Springer, 2006.
383+
[^5]: Christopher Bishop, *Pattern Recognition and Machine Learning*, Springer, 2006.

0 commit comments

Comments
 (0)