ETraceGraph#
- class braintrace.ETraceGraph(module_info: ModuleInfo, hidden_groups: Sequence[HiddenGroup], hid_path_to_group: Dict[Tuple[str, ...], HiddenGroup], hidden_param_op_relations: Sequence[HiddenParamOpRelation], hidden_perturb: HiddenPerturbation | None, diagnostics: Tuple[CompilationRecord, ...] = ())#
The overall compiled graph for the eligibility trace.
The eligibility trace graph, tracking the relationship between the etrace weights ParamState, the etrace variables HiddenState, and the etrace operations :pyETP primitives.
The following fields are included:
module_info: The model information, instance ofModuleInfo.hidden_groups: The hidden groups, sequence ofHiddenGroup.hid_path_to_group: The mapping from the hidden path to the hidden groupHiddenGroup.hidden_param_op_relations: The hidden parameter operation relations, sequence ofHiddenParamOpRelation.hidden_perturb: The hidden perturbation, instance ofHiddenPerturbation, or None.
Example:
>>> import braintrace >>> import brainstate >>> gru = braintrace.nn.GRUCell(10, 20) >>> gru.init_state() >>> inputs = brainstate.random.randn(10) >>> compiled_graph = braintrace.compile_etrace_graph(gru, inputs) >>> compiled_graph.dict().keys()
- explain(*, weight_path=None, hidden_path=None, kind=None)[source]#
Return compilation records filtered by weight path, hidden path, or kind.
weight_pathandhidden_pathmatch the record’sweight_pathexactly andhidden_pathsmembership respectively.kindmatchesCompilationRecord.kind. All are optional; with no filters the full diagnostic log is returned.
- hid_path_to_group: Dict[Tuple[str, ...], HiddenGroup]#
Alias for field number 2
Alias for field number 1
Alias for field number 3
Alias for field number 4
- module_info: ModuleInfo#
Alias for field number 0