75 [[nodiscard]]
int depth()
const {
return options_.
depth; }
76 [[nodiscard]] int64_t
num_inner()
const {
return (int64_t{1} << options_.
depth) - 1; }
78 [[nodiscard]] int64_t
num_inputs()
const {
return inputs_; }
79 [[nodiscard]] int64_t
num_classes()
const {
return classes_; }
96 [[nodiscard]]
double penalty()
const {
return penalty_; }
103 [[nodiscard]] std::vector<std::pair<int64_t, bool>>
PathTo(int64_t leaf)
const;
117 std::vector<double> p_;
118 std::vector<double> reach_;
119 std::vector<double> reach_leaf_;
120 std::vector<double> q_;
121 std::vector<double> mixture_;
122 double penalty_ = 0.0;
125 bool has_forwarded_ =
false;
Vendor-agnostic compute/memory backend. CPUBackend, CUDABackend (Phase 1.5), and HIPBackend (Phase 1....
Definition device_backend.hpp:248
y = x @ W + b, batched (x is (N, in_features), y is (N, out_features)) – migrated from the original u...
Definition linear_module.hpp:43
Base class for every layer type (LinearModule, Conv2DModule, activations, ...).
Definition module.hpp:78
Frosst and Hinton's soft decision tree, (N, inputs) to (N, classes) log-probabilities.
Definition soft_decision_tree.hpp:63
Tensor & leaf_logits()
The leaves' logits φ, (leaves, classes).
Definition soft_decision_tree.hpp:86
const std::vector< double > & leaf_probabilities() const
Definition soft_decision_tree.hpp:93
Tensor backward(const Tensor &grad_output) override
Computes the gradient w.r.t. this module's input, given the gradient w.r.t. its output....
bool supports_lrp_rule(LRPRule) const override
Whether propagate_relevance() implements rule (no silent fallback: callers such as ExplainerContext::...
Definition soft_decision_tree.hpp:69
double penalty() const
The last forward()'s balance penalty C, λ included; 0 when λ is 0. Add it to the loss you report: bac...
Definition soft_decision_tree.hpp:96
int64_t num_leaves() const
Definition soft_decision_tree.hpp:77
std::vector< double > LeafDistributions() const
The leaves' distributions softmax(φ), row-major (leaves, classes).
std::vector< int64_t > MostProbableLeaf() const
For each input of the last forward(), the leaf its most probable path ends at: the greedy path,...
OpType op_type() const override
This module's operation-category tag, for ComputationGraph node tagging.
Definition soft_decision_tree.hpp:70
int64_t num_inputs() const
Definition soft_decision_tree.hpp:78
std::vector< std::pair< int64_t, bool > > PathTo(int64_t leaf) const
The inner nodes on the path from the root to leaf, root first, and whether the path goes right at eac...
int64_t num_inner() const
Definition soft_decision_tree.hpp:76
Tensor forward_impl(const Tensor &input) override
The actual forward computation. Called by forward() after precondition checks.
std::vector< NamedParamRef > named_parameters() override
gates.weight, gates.bias and leaves.
int64_t num_classes() const
Definition soft_decision_tree.hpp:79
Tensor propagate_relevance(const Tensor &relevance_out, const LRPRuleConfig &config) override
Computes this module's contribution to LRP relevance propagation.
std::vector< NamedModuleRef > named_children() override
This module's direct sub-modules, each under the prefix its parameters carry in named_parameters(),...
int depth() const
Definition soft_decision_tree.hpp:75
LinearModule & gates()
The gates: column i of its (inputs, inner) weight and entry i of its bias are node i's w_i and b_i.
Definition soft_decision_tree.hpp:84
const SoftDecisionTreeOptions & options() const
Definition soft_decision_tree.hpp:80
SoftDecisionTree(int64_t inputs, int64_t classes, DeviceBackend *backend, SoftDecisionTreeOptions options={})
const std::vector< double > & right_probabilities() const
From the last forward(): each input's probability of going right at each inner node,...
Definition soft_decision_tree.hpp:92
N-dimensional tensor. Owns its data buffer exclusively; a DeviceBackend* is injected (not owned) – th...
Definition tensor.hpp:29
Dense/fully-connected layer – the reference Module implementation.
Abstract base every layer subclasses – NVI forward(), pure-virtual LRP contract.
Definition acquisition_functions.hpp:16
DeviceType
Which physical device a Tensor's buffer resides on.
Definition device_backend.hpp:17
OpType
The op-type tag a Node carries. Charter Part 2 §3: nodes are tagged by a small closed set of op types...
Definition op_type.hpp:19
LRPRule
The LRP rule family a module applies. Semantics follow Zennit 1.0.0 exactly (Anders et al....
Definition lrp_rule_config.hpp:21
Configuration for LRP relevance propagation: which rule a module applies and its hyperparameters....
Definition lrp_rule_config.hpp:72
SoftDecisionTree's settings.
Definition soft_decision_tree.hpp:44
float beta
The gates' inverse temperature β: larger is closer to a hard tree.
Definition soft_decision_tree.hpp:48
int depth
Levels of inner nodes: 2^depth leaves. Between 1 and 16.
Definition soft_decision_tree.hpp:46
uint64_t seed
The gates' weights and biases start uniform in ±1/√inputs, as nn.Linear's do; the leaves start at zer...
Definition soft_decision_tree.hpp:53
float penalty
The balance penalty's λ; 0 turns it off. Frosst and Hinton use 0.1 or so.
Definition soft_decision_tree.hpp:50