PolyWeave
Sigma-Pi layers, differentiable logic and reasoning.
22 nodes. Right-click any node in the editor to read this documentation in the app.
PolyWeave / Layersโ
๐ฌ Branch Energyโ
id polyweave_branch_energy ยท PolyWeave / Layers ยท Python export: yes
Diagnostic (recruitment metric B): on the given data, how much each branch moves the output - sigma_rms, pi_rms and pi_share (near 0 = the multiplicative branch is idle). Passes the layer through unchanged. In exported code it prints the result.
Inputs
| Port | Type | Description |
|---|---|---|
layer | Layer | A Sigma-Pi layer to inspect. |
data | Tensor | ndarray | A batch of inputs to measure the branches on. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | The input layer, unchanged (the metric is shown as the preview). |
๐ Conv Sigma-Pi 2Dโ
id polyweave_conv_sigma_pi_2d ยท PolyWeave / Layers ยท Python export: yes
Sigma-Pi convolutional block for [batch, channels, H, W] images: an ordinary convolution plus a multiplicative (pi) convolution branch. Input and output channel counts are equal.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
channels | int | Channels in and out (overrides the channels field). Overrides the Channels (in = out) field when connected. |
kernel_size | int | Square kernel side length (overrides the kernel_size field). Overrides the Kernel size field when connected. |
padding | int | Convolution padding (overrides the padding field). Overrides the Padding field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Conv Sigma-Pi layer, ready to chain or feed a Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Channels (in = out) | int | 16 | |
| Kernel size | int | 3 | |
| Padding | int | 1 | |
| Signed products (flagged approximation โ see docs) | checkbox | false | |
| Center product (silent product at init) | checkbox | false |
๐ Exponent Abs Meanโ
id polyweave_exponent_abs_mean ยท PolyWeave / Layers ยท Python export: yes
Diagnostic (recruitment metric A): mean(|exponent|) over the pi weights - how far the learned product departs from doing nothing (0 = idle). Passes the layer through unchanged. In exported code it prints the value.
Inputs
| Port | Type | Description |
|---|---|---|
layer | Layer | A Sigma-Pi layer to inspect. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | The input layer, unchanged (the metric is shown as the preview). |
๐ Occlusion Sensitivity (1D)โ
id polyweave_occlusion_sensitivity_1d ยท PolyWeave / Layers ยท Python export: yes
Which input features does the model rely on? Each feature window is replaced by a baseline value in turn and the drop in the model's (mean-reduced) response is measured. The chart shows the mean drop over the batch; the exported script returns the raw values.
Inputs
| Port | Type | Description |
|---|---|---|
model | Module | Model to probe (a layer node or a Graph Model). |
data | Tensor | ndarray | Batch of inputs, shape [N, features]. |
Outputs
| Port | Type | Description |
|---|---|---|
sensitivity | Tensor | Response drop per item and feature position, [N, positions]. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Window width (features) | int | 1 | |
| Stride | int | 1 | |
| Occlusion baseline value | float | 0.0 |
๐ Occlusion Sensitivity (2D)โ
id polyweave_occlusion_sensitivity_2d ยท PolyWeave / Layers ยท Python export: yes
Which image regions does the model rely on? A window-sized patch (all channels) is replaced by a baseline value at each position and the drop in the model's (mean-reduced) response is measured - the classic occlusion heatmap. The chart shows the mean over the batch; the exported script returns the raw values.
Inputs
| Port | Type | Description |
|---|---|---|
model | Module | Model to probe (a layer node or a Graph Model). |
data | Tensor | ndarray | Batch of images, shape [N, C, H, W]. |
Outputs
| Port | Type | Description |
|---|---|---|
sensitivity | Tensor | Response drop heatmap per image, [N, H_out, W_out]. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Window size (H/W pixels) | int | 3 | |
| Stride | int | 1 | |
| Occlusion baseline value | float | 0.0 | |
| Relative (fraction of base response โ exposes the AND-signature) | checkbox | false |
๐ Pi-Scale Meanโ
id polyweave_pi_scale_mean ยท PolyWeave / Layers ยท Python export: yes
Diagnostic: shows exp(pi_scale).mean() for a Sigma-Pi layer โ how strongly the multiplicative branch is gated in. Passes the layer through unchanged. In exported code it prints the value.
Inputs
| Port | Type | Description |
|---|---|---|
layer | Layer | A Sigma-Pi layer to inspect. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | The input layer, unchanged (the metric is shown as the preview). |
โ Poly Linearโ
id polyweave_poly_linear ยท PolyWeave / Layers ยท Python export: yes
Linear layer plus a low-rank quadratic (degree-2 factorisation-machine) branch. Rank sets the multiplicative capacity; rank 0 is a plain linear layer.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
in_features | int | Input size (overrides the in_features field). Overrides the In features field when connected. |
out_features | int | Output size (overrides the out_features field). Overrides the Out features field when connected. |
rank | int | Number of rank-1 bilinear factors (overrides the rank field). Overrides the Rank field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Poly linear layer, ready to chain or feed a Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| In features | int | 128 | |
| Out features | int | 10 | |
| Rank | int | 8 |
๐ Sigma-Pi Linearโ
id polyweave_sigma_pi_linear ยท PolyWeave / Layers ยท Python export: yes
Sigma-Pi fully-connected layer: an ordinary linear (sigma) branch plus a multiplicative (pi) branch that computes geometric products of the inputs with learned exponents, gated by a learnable scale. Drop-in for a Linear layer.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
in_features | int | Input size (overrides the in_features field). Overrides the In features field when connected. |
out_features | int | Output size (overrides the out_features field). Overrides the Out features field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Sigma-Pi linear layer, ready to chain or feed a Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| In features | int | 128 | |
| Out features | int | 10 | |
| Signed products (flagged approximation โ see docs) | checkbox | false | |
| Center product (silent product at init) | checkbox | false |
PolyWeave / Logicโ
โง Fuzzy ANDโ
id polyweave_fuzzy_and ยท PolyWeave / Logic ยท Python export: yes
Fuzzy conjunction. 'product' t-norm: a*b; 'min': min(a, b). Element-wise on tensors/arrays and differentiable.
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | First truth value(s), in [0, 1]. |
b | Tensor | ndarray | float | Second truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | a AND b. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| t-norm | select | product | product, min |
โผ Fuzzy NANDโ
id polyweave_fuzzy_nand ยท PolyWeave / Logic ยท Python export: yes
Fuzzy NAND: not(and(a, b)).
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | First truth value(s), in [0, 1]. |
b | Tensor | ndarray | float | Second truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | NOT (a AND b). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| t-norm | select | product | product, min |
โฝ Fuzzy NORโ
id polyweave_fuzzy_nor ยท PolyWeave / Logic ยท Python export: yes
Fuzzy NOR: not(or(a, b)).
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | First truth value(s), in [0, 1]. |
b | Tensor | ndarray | float | Second truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | NOT (a OR b). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| t-norm | select | product | product, min |
ยฌ Fuzzy NOTโ
id polyweave_fuzzy_not ยท PolyWeave / Logic ยท Python export: yes
Fuzzy negation: 1 - a (the standard complement). Element-wise and differentiable.
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | Truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | NOT a. |
โจ Fuzzy ORโ
id polyweave_fuzzy_or ยท PolyWeave / Logic ยท Python export: yes
Fuzzy disjunction. 'product' t-norm: a + b - a*b (probabilistic sum); 'min': max(a, b). Element-wise and differentiable.
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | First truth value(s), in [0, 1]. |
b | Tensor | ndarray | float | Second truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | a OR b. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| t-norm | select | product | product, min |
โ Fuzzy XORโ
id polyweave_fuzzy_xor ยท PolyWeave / Logic ยท Python export: yes
Fuzzy exclusive-or: or(a, b) - and(a, b). With 'product' this is a + b - 2ab; with 'min' it is |a - b|.
Inputs
| Port | Type | Description |
|---|---|---|
a | Tensor | ndarray | float | First truth value(s), in [0, 1]. |
b | Tensor | ndarray | float | Second truth value(s), in [0, 1]. |
Outputs
| Port | Type | Description |
|---|---|---|
truth | Tensor | a XOR b. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| t-norm | select | product | product, min |
๐ Soft Rule Layerโ
id polyweave_soft_rule_layer ยท PolyWeave / Logic ยท Python export: yes
n_rules learnable signed-literal conjunctions combined by a probabilistic OR - a soft, trainable disjunctive normal form (IF-THEN rules induced from data).
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
n_features | int | Width of the input truth vector (overrides the n_features field). Overrides the Input features field when connected. |
n_rules | int | Number of rules (conjunctions) to induce (overrides the n_rules field). Overrides the Number of rules field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Soft rule layer, ready to chain or feed a Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Input features | int | 8 | |
| Number of rules | int | 4 | |
| Signed (premises may be negated) | checkbox | true |
๐ Soft Signed Literalโ
id polyweave_soft_signed_literal ยท PolyWeave / Logic ยท Python export: yes
A single learnable conjunction over a truth vector: each premise is learned (in log space) as included, ignored or - when Signed - negated. A trainable AND of literals.
Inputs
| Port | Type | Description |
|---|---|---|
upstream | Layer | Previous layer. Leave unconnected for the model's first layer. |
n_features | int | Width of the input truth vector (overrides the n_features field). Overrides the Input features field when connected. |
Outputs
| Port | Type | Description |
|---|---|---|
layer | Layer | Soft literal layer, ready to chain or feed a Graph Model. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Input features | int | 8 | |
| Signed (premises may be negated) | checkbox | true |
PolyWeave / Reasoningโ
โ Add Ruleโ
id polyweave_kb_add_rule ยท PolyWeave / Reasoning ยท Python export: yes
Add one Horn-clause rule (premises -> conclusion) to the knowledge base and pass the same base on, so rules can be chained. Facts are created on first mention.
Inputs
| Port | Type | Description |
|---|---|---|
kb | PropKB | Knowledge base to add the rule to (Propositional KB or an earlier Add Rule). |
Outputs
| Port | Type | Description |
|---|---|---|
kb | PropKB | The same knowledge base, now including the rule. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Premises (comma-separated) | text | ||
| Conclusion | text | ||
| Rule name (optional) | text |
โ Entails?โ
id polyweave_entails ยท PolyWeave / Reasoning ยท Python export: yes
Ask whether the knowledge base entails a goal fact, given the initial facts. Outputs whether it does and how true it is.
Inputs
| Port | Type | Description |
|---|---|---|
chainer | ForwardChainer | From Forward Chainer. |
facts | Tensor | Starting truth vector, from Initial Facts. |
Outputs
| Port | Type | Description |
|---|---|---|
entailed | tuple[bool, float] | (entailed?, truth value of the goal). |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Goal fact | text |
โ๏ธ Forward Chainerโ
id polyweave_forward_chainer ยท PolyWeave / Reasoning ยท Python export: yes
Turn a finished knowledge base into a differentiable forward chainer that applies the rules repeatedly until nothing new is derived (the deductive closure).
Inputs
| Port | Type | Description |
|---|---|---|
kb | PropKB | The finished knowledge base. |
Outputs
| Port | Type | Description |
|---|---|---|
chainer | ForwardChainer | Forward chainer over the knowledge base. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| Max steps (must exceed the longest proof depth) | int | 10 | |
| t-norm | select | product | product, min |
๐ฏ Initial Factsโ
id polyweave_kb_initial_facts ยท PolyWeave / Reasoning ยท Python export: yes
Build the starting truth vector for a knowledge base: the listed facts are true (1.0), every other fact is false (0.0).
Inputs
| Port | Type | Description |
|---|---|---|
kb | PropKB | The finished knowledge base. |
Outputs
| Port | Type | Description |
|---|---|---|
facts | Tensor | Truth vector, shape (1, number of facts) โ wire into Run / Entails. |
Fields
| Field | Type | Default | Choices |
|---|---|---|---|
| True facts (comma-separated) | text |
๐ Propositional KBโ
id polyweave_prop_kb ยท PolyWeave / Reasoning ยท Python export: yes
An empty propositional knowledge base (named facts + Horn-clause rules). Chain Add Rule nodes onto it to build up the rules.
Outputs
| Port | Type | Description |
|---|---|---|
kb | PropKB | Empty knowledge base. |
โถ๏ธ Run Forward Chainerโ
id polyweave_run_forward_chainer ยท PolyWeave / Reasoning ยท Python export: yes
Run the chainer from the initial facts to the fixpoint and show the truth of every fact afterwards (the closure).
Inputs
| Port | Type | Description |
|---|---|---|
chainer | ForwardChainer | From Forward Chainer. |
facts | Tensor | Starting truth vector, from Initial Facts. |
Outputs
| Port | Type | Description |
|---|---|---|
closure | Tensor | Truth vector after chaining, shape (1, number of facts). |