neural_trees.HardRoutedExperts#
- class neural_trees.HardRoutedExperts(gate_weights, expert_weights, classes, n_features_in, depth, branching_factor)[source]#
Bases:
objectA trained mixture of experts with its gates read as hard routing decisions.
Each gating node sends a sample to its highest-weighted child, and the expert reached at the leaf produces the prediction. Everything runs in numpy; no PyTorch is involved.
Built by HierarchicalMixtureOfExperts.to_hard_router() rather than directly.
- Attributes:
- depthint
- branching_factorint
- classes_ndarray of shape (n_classes,)
- n_features_in_int
- gate_weights_list of (W1, b1, W2, b2)
One two-layer gating network per internal node, in breadth-first order.
- expert_weights_list of (W1, b1, W2, b2)
One two-layer expert network per leaf.
- export_text(feature_names=None, max_features=3, decimals=3) str[source]#
Render the routing tree, showing which features drive each gate.
A gating node is a two-layer network, not a single hyperplane, so there is no exact rule to print. What is shown is each gate’s input-layer sensitivity per feature, summed over hidden units, which says what the gate is looking at.