Raw observations are often high-dimensional or structured (a time series, a
set of summary statistics, an image) where feeding x straight into the
density estimator wastes capacity. An embedding network learns a low-
dimensional summary \(h = f_\psi(x)\) jointly with the density estimator,
so the conditioning path becomes \(q_\phi(\theta \mid f_\psi(x))\). This
mirrors sbi's embedding_net argument.
Usage
embedding_mlp(output_dim = 16L, hidden = c(64L, 64L))Value
An nsbi_embedding specification. It carries no torch objects (the
network is built lazily at fit time), so it is safe to construct without
torch installed.
Details
embedding_mlp() builds a multilayer-perceptron summary network: a stack of
fully connected ReLU layers mapping the (standardized) data to a vector of
output_dim features. Pass the result to npe() via embedding_net; it is
trained end to end with the estimator and its parameters live inside the
fitted network, so sampling and log_prob route through it automatically.
The embedding consumes the standardized data (the same z-scoring npe()
applies to x without an embedding), which keeps the summary network's
inputs on a common scale. Standardization of the features is intentionally
left to the network itself; the estimators operate on the raw embedding
output.
Examples
emb <- embedding_mlp(output_dim = 8, hidden = c(64, 64))
# fit <- npe(prior, simulator, density_estimator = "maf", embedding_net = emb)
