Giter Site home page Giter Site logo

Comments (4)

dgerlanc avatar dgerlanc commented on May 29, 2024 2

@aesara-devs/core, should we make RandomStream return RandomVariables with RandomVariable.inplace == True, instead of setting SharedVariable.default_updates on the generated RandomTypeSharedVariables?

Yes.

The reason we set SharedVariable.default_update is so that the aesara.function-compiled results will generate different samples between calls, as one would expect in a normal NumPy scenario.

I think it's fine to break this NumPy "compatibility" since we're effectively saying that the context for a call includes the state of the RandomStream. NumPy also assumes this, the state is just updated globally.

from aesara.

brandonwillard avatar brandonwillard commented on May 29, 2024 2

I think it's fine to break this NumPy "compatibility" since we're effectively saying that the context for a call includes the state of the RandomStream. NumPy also assumes this, the state is just updated globally.

Luckily, the end result of this proposed change wouldn't actually change any important user-facing behavior, aside from the way that in-place RNG updating can effectively be disabled by disabling default updates via the relevant aesara.function option. Basically, with these changes, when a graph is created with in-place RNG updating enabled, it stays that way, because it's set at the Op-level and not determined by the user and their use/non-use of the updates.

from aesara.

brandonwillard avatar brandonwillard commented on May 29, 2024

Here's the primary reason such a change wasn't made earlier:

Theano was designed to be "functional", in that its graphs were expected to contain objects with more or less no state (and/or loops). More importantly, the identity of RandomVariable nodes is tied to their inputs (as is the case for all Apply nodes), and the updating RNG objects in-places complicates this situation, because two RandomVariable nodes with the same in-place updated RNG inputs aren't actually equal.

This is the design issue we would need to address.

from aesara.

brandonwillard avatar brandonwillard commented on May 29, 2024

Just to be clear, I created this issue so that we can have a record of this approach and some important considerations regarding it.

In general, this issue relates directly to many other RandomVariable topics we've discussed in this repository, but most of those did/do not consider the introduction of some form of graph-level statefulness. (Ideally, we wouldn't even consider doing something like this, but our current use of SharedVariable.default_update leads to some severe development complications that warrant such considerations.)

For instance, going back to the basics of RandomVariable, one can—and probably should—use the output RNG states from one RandomVariable node as inputs to the next RandomVariable node and very naturally describe the update process graphically; however, this introduces long chain relationships between all RandomVariable nodes, and those complicate things.

The discussion in #1251 describes the above very well, and some possible improvements to the graph-level representation of RNG updates and RandomVariable. As mentioned in the discussion, those design improvements don't directly solve some of the efficiency (e.g. the need to copy RNG states before sampling in RandomVariable.perform, which is mostly an inherited NumPy issue) or usability (e.g. #898, #738) issues that one would hope to address more easily with explicit in-placing.

N.B. The approach in #1251 does fix some design issues that could help with the usability of chained RNG outputs, though, and that's important.

from aesara.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.