Comments (4)
@aesara-devs/core, should we make
RandomStream
returnRandomVariable
s withRandomVariable.inplace == True
, instead of settingSharedVariable.default_update
s on the generatedRandomTypeSharedVariable
s?
Yes.
The reason we set
SharedVariable.default_update
is so that theaesara.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.
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.
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.
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)
- Mention the need to pull tags when performing a development install HOT 6
- Error when `pip install -r requirements-rtd.txt` for contributing to docs
- RTD build failure HOT 1
- Random sampling JAX failures caused by `jax>=0.4.5`
- DeprecationWarning: numpy conversion of out-of-bound python integers HOT 2
- Remove deprecated "bin" package
- Possible small error in `GenGammaRV`: `"rng_state"` instead of `"jax_state"` HOT 1
- Error with git pre-hooks: Module "setuptools._distutils.errors" has no attribute "CompileError"
- Make `CholeskySolve` extend `SolveBase`
- "error in pydot2 setup command: use_2to3 is invalid" while installing requirements-rtd.txt dependencies HOT 1
- aesara.scan IndexError
- Add rewrites to lift/flatten `Subtensor`s applied to `IncSubtensor`s
- Do you still need the MapIter? HOT 5
- Import aesara fails with numpy 1.26 HOT 2
- NumPy 1.26 causes error HOT 6
- Warnings emitted on import in Windows HOT 1
- Add support for `FFT` functions HOT 1
- Memory leak with a particular combination of operations HOT 5
- Python 3.12 import failure: `ModuleNotFoundError: No module named 'numpy.distutils'`
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from aesara.