returnn.frontend._random_journal
#
Utilities to record and playback calls to random. This is useful to be able to compare different backends even when they use random numbers.
It assumes that the order of random calls is deterministic and consistent between backends.
The logic becomes more complex when control flow is involved like conditionals or loops. We are also storing the control flow context in the journal.
- class returnn.frontend._random_journal.RandomJournal[source]#
random journal. see module docstring
- append(*, distribution: str, mean: int | float | Tensor | None = None, stddev: int | float | Tensor | None = None, bound: int | float | Tensor | None = None, minval: int | float | Tensor | None = None, maxval: int | float | Tensor | None = None, seed: int | Sequence[int] | ndarray | None = None, static: bool | None = None, out: Tensor[ndarray] | None)[source]#
- get_next(*, new_out_template: Tensor | None = None) RandomJournalEntry [source]#
read next
- add_graph_reader_node(out)[source]#
In graph mode, if reading (get_next), at cgraph construction time, register that we are reading from the journal now in the current context. This is used in
get_recent_graph_reader_node_in_accessible_ctx()
.
- class returnn.frontend._random_journal.RandomJournalEntry(out: Tensor[ndarray] | None, control_flow_ctx: ControlFlowContext | None, run_ctx: RunCtx, distribution: str, mean: int | float | Tensor | None = None, stddev: int | float | Tensor | None = None, bound: int | float | Tensor | None = None, minval: int | float | Tensor | None = None, maxval: int | float | Tensor | None = None, seed: int | Sequence[int] | ndarray | None = None, static: bool | None = None)[source]#
entry
- control_flow_ctx: ControlFlowContext | None[source]#