Skip to content

Ensemble expected usage #41

Description

@johnviljoen

I am trying to integrate distreqx into some work I am currently doing and I had a question about expected usage.

I need a batch of MultivariateNormalDiag's so I have been creating ensembles with eqx.filter_vmap. Upon creation I can then .sample(key) the created vmapped distribution successfully (with a non-vmapped key), but other methods of the distributions class cannot work without first being integrated.

    eqx_pi = eqx.filter_vmap(dist.MultivariateNormalDiag)(
        eqx_mean,
        eqx_scale,                        
    )
    eqx_pi_log_prob = lambda d, a: d.log_prob(a)
    eqx_pi_entropy = lambda d: d.entropy()
    eqx_samp  = eqx_pi.sample(key)                      # works
    ent = eqx.filter_vmap(eqx_pi_entropy)(eqx_pi)       # works
    lp = eqx.filter_vmap(eqx_pi_log_prob)(eqx_pi, eqx_samp) # works

    ent = eqx_pi.entropy() # evaluates, incorrect values, correct shape
    lp = eqx_pi.log_prob(eqx_samp) # evaluates, incorrect values (all same), correct shape

Why can .sample work in this case (is it specific to my example)? Is this expected behaviour/am I using this incorrectly?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions