From b4d413e3d0aa548095ed450ac0a506af12d25a85 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 3 May 2024 11:34:27 +1000 Subject: [PATCH 1/3] FIX: fixes for PDF builder --- lectures/bayes_nonconj.md | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/lectures/bayes_nonconj.md b/lectures/bayes_nonconj.md index 0443499..e32b816 100644 --- a/lectures/bayes_nonconj.md +++ b/lectures/bayes_nonconj.md @@ -315,16 +315,16 @@ Formula {eq}`eq:ELBO` is called the evidence lower bound (ELBO). A standard optimization routine can used to search for the optimal $\phi$ in our parametrized distribution $q_{\phi}(\theta)$. -The parameterized distribution $q_{\phi}(\theta)$ is called the **variational distribution**. +The parameterized distribution $q_{\phi}(\theta)$ is called the **variational distribution**. We can implement Stochastic Variational Inference (SVI) Numpyro using the `Adam` gradient descent algorithm to approximate posterior. We use two sets of variational distributions: Beta and TruncatedNormal with support $[0,1]$ - - Learnable parameters for the Beta distribution are (alpha, beta), both of which are positive. - - Learnable parameters for the Truncated Normal distribution are (loc, scale). +- Learnable parameters for the Beta distribution are (alpha, beta), both of which are positive. +- Learnable parameters for the Truncated Normal distribution are (loc, scale). - We restrict the truncated Normal paramter 'loc' to be in the interval $[0,1]$. +We restrict the truncated Normal parameter 'loc' to be in the interval $[0,1]$ ## Implementation @@ -335,30 +335,24 @@ We have constructed a Python class `BaysianInference` that requires the followin - `name_dist`: a string that specifies distribution names The (`param`, `name_dist`) pair includes: -- ('beta', alpha, beta) +- ('beta', alpha, beta) - ('uniform', upper_bound, lower_bound) - - ('lognormal', loc, scale) - Note: This is the truncated log normal. - - ('vonMises', kappa), where kappa denotes concentration parameter, and center location is set to $0.5$. - Note: When using `Numpyro`, this is the **shifted** distribution. - - ('laplace', loc, scale) - Note: This is the truncated Laplace The class `BaysianInference` has several key methods : - `sample_prior`: - This can be used to draw a single sample from the given prior distribution. - - `show_prior`: - Plots the approximate prior distribution by repeatedly drawing samples and fitting a kernal density curve. - - `MCMC_sampling`: - INPUT: (data, num_samples, num_warmup=1000) - Take a `np.array` data and generate MCMC sampling of posterior of size `num_samples`. - - `SVI_run`: - INPUT: (data, guide_dist, n_steps=10000) - guide_dist = 'normal' - use a **truncated** normal distribution as the parametrized guide From e513849701569bbf2ec0870ae7d7c12836d199c6 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 3 May 2024 11:49:33 +1000 Subject: [PATCH 2/3] enable -n for pdflatex builds --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 2e3b487..bd84137 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -63,7 +63,7 @@ jobs: - name: Build PDF from LaTeX shell: bash -l {0} run: | - jb build lectures --builder pdflatex --path-output ./ -W --keep-going + jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going mkdir -p _build/html/_pdf cp -u _build/latex/*.pdf _build/html/_pdf - name: Upload Execution Reports (LaTeX) From cb8dbfb117af92b0802582501b3f7ef21ed73206 Mon Sep 17 00:00:00 2001 From: mmcky Date: Fri, 3 May 2024 12:11:44 +1000 Subject: [PATCH 3/3] upload build folder for pdflatex builder --- .github/workflows/ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index bd84137..719dbba 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -66,6 +66,11 @@ jobs: jb build lectures --builder pdflatex --path-output ./ -n -W --keep-going mkdir -p _build/html/_pdf cp -u _build/latex/*.pdf _build/html/_pdf + - name: Upload build folder + uses: actions/upload-artifact@v4 + with: + name: build-folder + path: _build - name: Upload Execution Reports (LaTeX) uses: actions/upload-artifact@v4 if: failure()