Skip to content
Back to skills

Variational Inference

ASecurity

"Use ZhuSuan for ELBO, IWAE, inclusive KL, importance-sampling

  • 247 stars
  • 0 votes
  • 0 copies
  • 1 view
  • Added September 9, 2026
toolsgoapi

Works with

  • api

Security analysis

A100/100

Pro scans all 6 files and shows the line behind each finding

Scanned September 9, 2026

npx -y skills add VectorSpaceLab/AREX-Skill --skill variational-inference --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Variational Inference?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Variational Inference
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/vectorspacelab-variational-inference/badge)](https://www.skillsdirectory.com/skills/vectorspacelab-variational-inference)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: variational-inference
description: "Use ZhuSuan for ELBO, IWAE, inclusive KL, importance-sampling
  likelihoods, normalizing flows, and VAE/BNN/SVGP-style variational workflows."
metadata:
  disco-role: operating
disable-model-invocation: true
license: MIT
---

# Variational Inference

Use this sub-skill when the task is about learning latent-variable models with
ELBO-style or importance-weighted objectives.

## Read this when

- the user names `elbo`, `importance_weighted_objective`, `klpq`, `is_loglikelihood`,
  `sgvb`, `reinforce`, `vimco`, `RWS`, `IWAE`, `VAE`, `BNN`, or `SVGP`
- the task is about variational posteriors, multi-sample objectives, or
  importance-sampling based marginal likelihood estimates
- the user wants to stack normalizing flows onto a variational distribution
- the request is about semi-supervised VAE or sigmoid-belief-network examples

## What this sub-skill owns

- ELBO, inclusive KL, and importance-weighted objectives
- gradient estimators: SGVB, REINFORCE, VIMCO, and importance-sampling wake-sleep
- `is_loglikelihood` for marginal log-likelihood estimation
- normalizing flows: planar and inverse autoregressive flows
- the variational example families: VAE, BNN, semi-supervised VAE, SBN, and SVGP

## What this sub-skill does not own

- HMC, SGLD, SGHMC, SGNHT, AIS, or sampling diagnostics
- core Bayesian-network modeling basics
- generic TensorFlow training unrelated to probabilistic inference

## Start here

1. Read `references/variational-workflows.md` for the workflow map.
2. Read `references/api-reference.md` for exact objective and flow signatures.
3. Read `references/troubleshooting.md` for common estimator and axis mistakes.
4. Run `scripts/vi_smoke.py` after environment setup to check ELBO, IWAE,
   importance-sampling likelihood, flows, and the GP helper path.

## Common tasks

### Train a VAE / BNN / SVGP

- Build a generative `MetaBayesianNet` with latent variables and observations.
- Build a variational `BayesianNet` that produces the latent samples and their
  log probabilities.
- Use `zs.variational.elbo(...)` or
  `zs.variational.importance_weighted_objective(...)`.
- Optimize `lower_bound.sgvb()` for reparameterized latents, or
  `lower_bound.reinforce()` / `lower_bound.vimco()` when the latent variables
  are not reparameterizable.

### Add normalizing flows

- Pull the latent samples and log probabilities from `q_net.query(...)`.
- Pass them through `planar_normalizing_flow(...)` or
  `inv_autoregressive_flow(...)`.
- Feed the transformed samples and adjusted log probabilities back into the
  variational objective.

### Estimate marginal log likelihood

- Use `zs.is_loglikelihood(...)` with the same latent samples and proposal as
  the variational model.
- Remember that importance-sampling estimates are only as good as the proposal;
  they are often used as evaluation metrics, not as the main training target.

## Good entry points

- `zhusuan/variational/base.py`
- `zhusuan/variational/exclusive_kl.py`
- `zhusuan/variational/inclusive_kl.py`
- `zhusuan/variational/monte_carlo.py`
- `zhusuan/evaluation.py`
- `zhusuan/transform.py`
- `scripts/vi_smoke.py`
- `sub-skills/variational-inference/scripts/gp_helpers.py`

## Routing hints

- If the request is only about the core probabilistic graph, route to
  `modeling-primitives`.
- If the request is about posterior sampling, route to `mcmc-and-sampling`.
- If the task is about training scripts that merely use TensorFlow optimizers
  without a probabilistic objective, a non-ZhuSuan skill may fit better.

Files in this skill

  • SKILL.md3.5 KB
  • references/api-reference.md1.4 KB
  • references/troubleshooting.md1.5 KB
  • references/variational-workflows.md2.2 KB
  • scripts/gp_helpers.py2.7 KB
  • scripts/vi_smoke.py2 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.