A Julia implementation of triangular transport maps for variational inference.
# From Julia REPL
pkg> add TransportMapsHere's a simple example showing how to construct a transport map for a "banana" distribution:
using TransportMaps
using Distributions
# Create a 2D polynomial map with degree 2 and Softplus rectifier
M = PolynomialMap(2, 2, Normal(), Softplus())
# Set up quadrature for optimization
quadrature = GaussHermiteWeights(3, 2)
# Define target density (banana distribution)
target_density(x) = logpdf(Normal(), x[1]) + logpdf(Normal(), x[2] - x[1]^2)
target = MapTargetDensity(target_density)
# Optimize the map coefficients
result = optimize!(M, target, quadrature)
# Generate samples by mapping standard Gaussian samples
samples_z = randn(1000, 2)
# Matrix input automatically uses multithreading for better performance
mapped_samples = evaluate(M, samples_z)
# Evaluate map quality
variance_diag = variance_diagnostic(M, target, samples_z)- Triangular polynomial transport maps with various polynomial bases
- Multiple rectifier functions: Softplus, ShiftedELU, Identity
- Quadrature integration schemes: Gauss-Hermite, Monte Carlo, Latin Hypercube
- Automatic optimization of map coefficients via KL divergence minimization
- Multithreaded evaluation for processing multiple points efficiently
- Matrix input support for all core functions (evaluate, inverse, jacobian, etc.)
Please refer to the documentation for more extensive examples and explanations.
Related implementations of transport maps are:
- ATM: Matlab code for adaptive transport maps [1]
- MParT: C++-based library for transport maps [2]
- TransportBasedInference.jl: Julia implementation of adaptive transport maps (ATM) and Kalman filters
- SequentialMeasureTransport.jl: Julia implementation of transport maps from sum-of-squares densities [3]
- Triangular-Transport-Toolbox: Python code for the triangular transport tutorial paper [4]
- Baptista, R., Marzouk, Y., & Zahm, O. (2023). On the Representation and Learning of Monotone Triangular Transport Maps. Foundations of Computational Mathematics. https://doi.org/10.1007/s10208-023-09630-x
- Parno, M., Rubio, P.-B., Sharp, D., Brennan, M., Baptista, R., Bonart, H., & Marzouk, Y. (2022). MParT: Monotone Parameterization Toolkit. Journal of Open Source Software, 7(80), 4843. https://doi.org/10.21105/joss.04843
- Zanger, B., Zahm, O., Cui, T., & Schreiber, M. (2024). Sequential transport maps using SoS density estimation and
$α$ -divergences (No. arXiv:2402.17943). arXiv. https://doi.org/10.48550/arXiv.2402.17943 - Ramgraber, M., Sharp, D., Provost, M. L., & Marzouk, Y. (2025). A friendly introduction to triangular transport (No. arXiv:2503.21673). arXiv. https://doi.org/10.48550/arXiv.2503.21673
This project is licensed under the MIT License - see the LICENSE file for details.
If you use TransportMaps.jl in your research, please cite:
@software{transportmaps_jl,
title = {TransportMaps.jl: Triangular transport maps for variational inference},
author = {Fritsch, Lukas and Grashorn, Jan},
year = {2025},
url = {https://github.com/JuliaUQ/TransportMaps.jl}
}