Skip to main content

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

PortTypeDescription
layerLayerA Sigma-Pi layer to inspect.
dataTensor | ndarrayA batch of inputs to measure the branches on.

Outputs

PortTypeDescription
layerLayerThe 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

PortTypeDescription
upstreamLayerPrevious layer. Leave unconnected for the model's first layer.
channelsintChannels in and out (overrides the channels field). Overrides the Channels (in = out) field when connected.
kernel_sizeintSquare kernel side length (overrides the kernel_size field). Overrides the Kernel size field when connected.
paddingintConvolution padding (overrides the padding field). Overrides the Padding field when connected.

Outputs

PortTypeDescription
layerLayerConv Sigma-Pi layer, ready to chain or feed a Graph Model.

Fields

FieldTypeDefaultChoices
Channels (in = out)int16
Kernel sizeint3
Paddingint1
Signed products (flagged approximation โ€” see docs)checkboxfalse
Center product (silent product at init)checkboxfalse

๐Ÿ“ 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

PortTypeDescription
layerLayerA Sigma-Pi layer to inspect.

Outputs

PortTypeDescription
layerLayerThe 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

PortTypeDescription
modelModuleModel to probe (a layer node or a Graph Model).
dataTensor | ndarrayBatch of inputs, shape [N, features].

Outputs

PortTypeDescription
sensitivityTensorResponse drop per item and feature position, [N, positions].

Fields

FieldTypeDefaultChoices
Window width (features)int1
Strideint1
Occlusion baseline valuefloat0.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

PortTypeDescription
modelModuleModel to probe (a layer node or a Graph Model).
dataTensor | ndarrayBatch of images, shape [N, C, H, W].

Outputs

PortTypeDescription
sensitivityTensorResponse drop heatmap per image, [N, H_out, W_out].

Fields

FieldTypeDefaultChoices
Window size (H/W pixels)int3
Strideint1
Occlusion baseline valuefloat0.0
Relative (fraction of base response โ€” exposes the AND-signature)checkboxfalse

๐Ÿ“ˆ 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

PortTypeDescription
layerLayerA Sigma-Pi layer to inspect.

Outputs

PortTypeDescription
layerLayerThe 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

PortTypeDescription
upstreamLayerPrevious layer. Leave unconnected for the model's first layer.
in_featuresintInput size (overrides the in_features field). Overrides the In features field when connected.
out_featuresintOutput size (overrides the out_features field). Overrides the Out features field when connected.
rankintNumber of rank-1 bilinear factors (overrides the rank field). Overrides the Rank field when connected.

Outputs

PortTypeDescription
layerLayerPoly linear layer, ready to chain or feed a Graph Model.

Fields

FieldTypeDefaultChoices
In featuresint128
Out featuresint10
Rankint8

๐ŸŒ€ 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

PortTypeDescription
upstreamLayerPrevious layer. Leave unconnected for the model's first layer.
in_featuresintInput size (overrides the in_features field). Overrides the In features field when connected.
out_featuresintOutput size (overrides the out_features field). Overrides the Out features field when connected.

Outputs

PortTypeDescription
layerLayerSigma-Pi linear layer, ready to chain or feed a Graph Model.

Fields

FieldTypeDefaultChoices
In featuresint128
Out featuresint10
Signed products (flagged approximation โ€” see docs)checkboxfalse
Center product (silent product at init)checkboxfalse

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

PortTypeDescription
aTensor | ndarray | floatFirst truth value(s), in [0, 1].
bTensor | ndarray | floatSecond truth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensora AND b.

Fields

FieldTypeDefaultChoices
t-normselectproductproduct, min

โŠผ Fuzzy NANDโ€‹

id polyweave_fuzzy_nand ยท PolyWeave / Logic ยท Python export: yes

Fuzzy NAND: not(and(a, b)).

Inputs

PortTypeDescription
aTensor | ndarray | floatFirst truth value(s), in [0, 1].
bTensor | ndarray | floatSecond truth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensorNOT (a AND b).

Fields

FieldTypeDefaultChoices
t-normselectproductproduct, min

โŠฝ Fuzzy NORโ€‹

id polyweave_fuzzy_nor ยท PolyWeave / Logic ยท Python export: yes

Fuzzy NOR: not(or(a, b)).

Inputs

PortTypeDescription
aTensor | ndarray | floatFirst truth value(s), in [0, 1].
bTensor | ndarray | floatSecond truth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensorNOT (a OR b).

Fields

FieldTypeDefaultChoices
t-normselectproductproduct, min

ยฌ Fuzzy NOTโ€‹

id polyweave_fuzzy_not ยท PolyWeave / Logic ยท Python export: yes

Fuzzy negation: 1 - a (the standard complement). Element-wise and differentiable.

Inputs

PortTypeDescription
aTensor | ndarray | floatTruth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensorNOT 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

PortTypeDescription
aTensor | ndarray | floatFirst truth value(s), in [0, 1].
bTensor | ndarray | floatSecond truth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensora OR b.

Fields

FieldTypeDefaultChoices
t-normselectproductproduct, 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

PortTypeDescription
aTensor | ndarray | floatFirst truth value(s), in [0, 1].
bTensor | ndarray | floatSecond truth value(s), in [0, 1].

Outputs

PortTypeDescription
truthTensora XOR b.

Fields

FieldTypeDefaultChoices
t-normselectproductproduct, 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

PortTypeDescription
upstreamLayerPrevious layer. Leave unconnected for the model's first layer.
n_featuresintWidth of the input truth vector (overrides the n_features field). Overrides the Input features field when connected.
n_rulesintNumber of rules (conjunctions) to induce (overrides the n_rules field). Overrides the Number of rules field when connected.

Outputs

PortTypeDescription
layerLayerSoft rule layer, ready to chain or feed a Graph Model.

Fields

FieldTypeDefaultChoices
Input featuresint8
Number of rulesint4
Signed (premises may be negated)checkboxtrue

๐Ÿ“ 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

PortTypeDescription
upstreamLayerPrevious layer. Leave unconnected for the model's first layer.
n_featuresintWidth of the input truth vector (overrides the n_features field). Overrides the Input features field when connected.

Outputs

PortTypeDescription
layerLayerSoft literal layer, ready to chain or feed a Graph Model.

Fields

FieldTypeDefaultChoices
Input featuresint8
Signed (premises may be negated)checkboxtrue

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

PortTypeDescription
kbPropKBKnowledge base to add the rule to (Propositional KB or an earlier Add Rule).

Outputs

PortTypeDescription
kbPropKBThe same knowledge base, now including the rule.

Fields

FieldTypeDefaultChoices
Premises (comma-separated)text
Conclusiontext
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

PortTypeDescription
chainerForwardChainerFrom Forward Chainer.
factsTensorStarting truth vector, from Initial Facts.

Outputs

PortTypeDescription
entailedtuple[bool, float](entailed?, truth value of the goal).

Fields

FieldTypeDefaultChoices
Goal facttext

โ›“๏ธ 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

PortTypeDescription
kbPropKBThe finished knowledge base.

Outputs

PortTypeDescription
chainerForwardChainerForward chainer over the knowledge base.

Fields

FieldTypeDefaultChoices
Max steps (must exceed the longest proof depth)int10
t-normselectproductproduct, 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

PortTypeDescription
kbPropKBThe finished knowledge base.

Outputs

PortTypeDescription
factsTensorTruth vector, shape (1, number of facts) โ€” wire into Run / Entails.

Fields

FieldTypeDefaultChoices
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

PortTypeDescription
kbPropKBEmpty 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

PortTypeDescription
chainerForwardChainerFrom Forward Chainer.
factsTensorStarting truth vector, from Initial Facts.

Outputs

PortTypeDescription
closureTensorTruth vector after chaining, shape (1, number of facts).