WithRandomSeed¶
Run the given computational graph with a random seed sequence initialized to the given seed.
The graph can draw one or more successive seed(s) from the sequence using the Draw Random Seed node. This node is nestable, and can provide, for example a different, independent sequence of seeds to a sub-computation (meaning a computation that is wired into that node's graph port), while the node itself is part of a larger computation that is also using a random seed sequence. Note: this node will also establish a context for use with hk.next_rng_key() if this node is being used inside a context NetTransform context. Version 0.9.0
Ports/Properties¶
graph¶
Computation to run.
- verbose name: Graph
- default value: None
- port type: GraphPort
- value type: Graph
graph__signature¶
Optionally the slotname of a Placeholder node that shall mark the starting point of the graph that runs under the with context. As with all "With" context manager nodes in NeuroPype, the graph that runs under the context managed by this node is preceding the context manager node in the graph, rather than following it. This is accomplished by wiring the final node of the graph that shall execute under the governance of the context manager into the "graph" input port of the subsequent "With" node. In graphical UIs, this edge will be drawn in dotted style to indicate that this is not normal forward data flow where first the preceding node executes and then the subsequent node receives its output, but that instead the subsequent node (the context manager) receives a portion of the preceding graph, which it then runs in such a way that the context applies. You can use a "tilde" binding, spelled as (~), which affects the same nodes that a then or else branch in an IfElse node would control, which is normally what one would expect. However, note that this can have sometimes the unexpected consequence that simply wiring a value into your graph may "infect" an upstream portion of the graph with unintentionally running under the context, too. As an alternative, you can instead rely on a named Placeholder node to mark the beginning of the managed graph. The typical way to do this is to list a single placeholder name, e.g., (with), and then to create a Placeholder in your graph whose slotname is set to "with". Then, only the nodes that are downstream of (i.e., formally depending on) that placeholder will run under the context defined by the "With" node. In this case you need to make everything that shall be part of the context dependent on the placeholder, which can be accomplished by wiring the update output port of the Placeholder into the update input port of any nodes that shall run under the context (this dependency propagates down the graph, so you don't need to wire it to every node, just to the first node(s) that you want to be part of the context). The result is that any use of the Draw Random Seed node in the managed graph will draw a seed from the sequence initialized by this node. This node can also be nested (see documentation of the equivalent setting in WithCoreLimit for more details).
- verbose name: Graph [Tag]
- default value: (~)
- port type: Port
- value type: object (can be None)
result¶
Result of the computation.
- verbose name: Result
- default value: None
- port type: DataPort
- value type: object (can be None)
- data direction: OUT
initial_seed¶
Seed for generated random number sequence. This can be either a splittable seed as generated by Create Random Seed or a plain integer seed.
- verbose name: Initial Seed
- default value: None
- port type: Port
- value type: AnyNumeric (can be None)
supply_haiku¶
Supply the haiku library with its own sequence of random seeds derived from the given initial seed. This will only work if used within a NetTransform context, and is equivalent to a call to hk.with_rng(initial_seed).
- verbose name: Also Generate Haiku Sequence
- default value: False
- port type: BoolPort
- value type: bool (can be None)
supply_bayes¶
Supply nodes in the Bayesian package node with automatic random seeds derived from the given initial seed. This is mainly useful if you aim to run stochastic models plain without using any of the inference nodes, which provide their own seed.
- verbose name: Expose To Bayes Nodes
- default value: False
- port type: BoolPort
- value type: bool (can be None)
is_global¶
If True, the context implicitly applies to the entire graph (except for those parts that are configuring the context itself). In this case the node must not have anything wired into its graph input and must not have any successors.
- verbose name: Is Global
- default value: False
- port type: BoolPort
- value type: bool (can be None)
supply_randomsample¶
- verbose name: Supply Randomsample
- default value: None
- port type: AliasPort
- value type: bool (can be None)
set_breakpoint¶
Set a breakpoint on this node. If this is enabled, your debugger (if one is attached) will trigger a breakpoint.
- verbose name: Set Breakpoint (Debug Only)
- default value: False
- port type: BoolPort
- value type: bool (can be None)
metadata¶
User-definable meta-data associated with the node. Usually reserved for technical purposes.
- verbose name: Metadata
- default value: {}
- port type: DictPort
- value type: dict (can be None)