jax_privacy.matrix_factorization.banded.optimize#
- jax_privacy.matrix_factorization.banded.optimize(n, *, bands, C=None, A=None, max_optimizer_steps=100, reduction_fn=<function mean>, scan_fn=<function scan>, callback=<function <lambda>>)[source]#
Optimize the strategy using a gradient-based method.
Note that this function benefits substantially from GPUs. This function is primarily supported to aid in reproducing results from McKenna (2024) In practice, we recommend using a banded Toeplitz strategy instead (see
optimize_banded_toeplitz()), which are <0.5% suboptimal in the regimes of most interest (\(n \ge 1000\), \(b \le 32\)).The strategies produced by this procedure can be used in both single- and multi-participation settings – both (k, b)-min-sep and (k, b)-fixed epoch order, as described in Choquette-Choo et al. (2023), as long as the number of bands in \(C\) is less than or equal to the (minimum) separation between contributions from the same user.
- Parameters:
n (
int) – The number of training iterations the strategy is configured for.bands (
int) – The number of bands in the strategy.C (
ColumnNormalizedBanded|None) – The initial strategy to be optimized.A (
StreamingMatrix|None) – The target workload.max_optimizer_steps (
int) – The maximum number of iterations to optimize for.reduction_fn (
Callable[[Array],Array]) – A function that converts per query squared errors to a scalar. Usejnp.meanto optimize mean-squared-error,jnp.maxto optimize max squared error, orlambda v: v[-1]to optimize last iterate squared error.scan_fn (
Any) – Either'equinox','dinosaur', or a function with the same signature asjax.lax.scan(). Using'equinox'or'dinosaur'is helpful for doing strategy optimization on GPUs for largen, since it allows the scan function used internally byper_query_errorto be checkpointed, avoiding OOM errors during backpropagation.callback (
Callable[[CallbackArgs],None|bool]) – A function to call after each optimization iteration. Seeoptimize()for details.
- Return type:
- Returns:
An optimized strategy having the same structure as
C.