Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    that would be an answer to a lot of clone-like use cases
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    Trying to see what you mean by non-inplace replacement.
    a = at.scalar('a')
    b = a + 1; b.name = 'b'
    c = b + 1; c.name = 'c'
    fg = FunctionGraph([a], [c], clone=False)
    fg.replace(b, at.sin(a))
    Would anything change in that toy example under the hood?
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    yeah, you've gotta test the bad and the good
    if only to set expectations
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    Totally unrelated this is interesting. They are suggesting there is no need for R_Ops at all: Theano/Theano#6400
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    yeah, I remember that one
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    This is the blogpost where they presented it: https://j-towns.github.io/2017/06/12/A-new-trick.html
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    it's a pretty natural idea, from what I recall
    try porting that PR to Aesara
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    I think they were blocked with special behavior of OpFromGraphs but I can try to open a draft and see what we get
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    that's easy enough to fix
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    Would it be too insane to add aliases for numpy constans (np.pi, np.inf, np.e...) in aesara.tensor?
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    to account for floatX?
    or to reduce the need to explicitly import numpy in some cases?
    either one is probably a reason enough
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    The second one. So that we can just write at.sqrt(x + at.pi) or at.switch(..., ..., at.inf)
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    ok
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    They only have a handful of constants, ignoring their own aliases: https://numpy.org/doc/stable/reference/constants.html
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    Next aesara-family library idea aevmap?
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    what does the vmap represent?
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    JAX's vmap behavior
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    what part of it?
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    Vectorization of "arbitrary" subgraphs. I have tried this in the past to vectorize a model logp, and the best I could come up with was OpFromGraph + Scan
    Which for a small model was no better than a Python list comprehension
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    this all depends on exactly what vectorization means in this context
    for instance, if it's more directly aligned with NumPy-like ufuncs, then that's already covered by Aesara's Composite Op
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    That would be more in line with numpy.vectorize (although that one does nothing clever), I think?
    That's what Composite is more like right? Builds on top of scalar operators
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    yeah, this is all very overlapping functionality
    same with Elemwise
    but, yes, there is no numpy.vectorize-like helper function in Aesara
    and I don't recall jax.vmap doing anything particularly special
    it seemed quite literally like a numpy.vectorize clone
    the effective difference being that the end result is a JITed function
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    I think one big difference is that numpy.vectorize requires a base function that works only with scalars, whereas vmap can be built on top of tensor functions?
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    I think numpy.vectorize can handle non-scalar functions
    that's why you can specify a signature with explicit dimensions for each input
    yeah, jax.vmap looks like an clone of numpy.vectorize
    with a somewhat different interface
    e.g. specified in terms of numbers of axes
    or labeled axes?
    yeah, it looks like their explicit version of numpy.vectorize just constructs vmap calls
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    anyway, we could provide a numpy.vectorize helper function
    Ricardo Vieira
    @ricardov94:matrix.org
    [m]
    TIL about the signature keyword:
    import numpy as np
    
    def dirichlet_logp(a, x):
        return st.dirichlet(a).logpdf(x)
    
    vfunc = np.vectorize(dirichlet_logp, signature='(n),(n)->()')
    vfunc(np.arange(1, 10).reshape(3, 3), np.ones(3)/3)
    brandonwillard
    @brandonwillard:matrix.org
    [m]
    yeah, it's pretty useful
    this kind of logic is essentially what we're doing in the RandomVariable class interface