rnel.nn
¶
Neural RNEL (requires PyTorch): typed evidential head and per-source evidential network.
RNELHead: features -> evidence (e_T, e_F, e_C, e_U, e_N) -> tuple of Definition 8.1 (typed labels). PerSourceEvidential: one binary opinion per piece of evidence, trained with true/false claim labels only; contradiction is read between sources (Definition 8.4), before fusion (Proposition 8.3).
TYPES = ('T', 'F', 'C', 'U', 'N')
module-attribute
¶
RNELHead
¶
Bases: Module
Linear map from features to non-negative typed evidence (softplus), order T, F, C, U, N.
Source code in src/rnel/nn.py
21 22 23 24 25 26 27 28 29 | |
PerSourceEvidential
¶
Bases: Module
Shared network phi applied to every (evidence, claim) pair -> binary evidence (e_T, e_F).
forward(x, mask): x (B, P, d) pieces, mask (B, P). Returns claim evidence (mean over pieces) and per-piece evidence. Train with typed_evidential_loss on the claim evidence and labels T=0, F=1.
Source code in src/rnel/nn.py
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
phi = nn.Sequential(nn.Linear(in_dim, hidden), nn.ReLU(), nn.Dropout(dropout), nn.Linear(hidden, hidden), nn.ReLU(), nn.Dropout(dropout))
instance-attribute
¶
out = nn.Linear(hidden, 2)
instance-attribute
¶
forward(x, mask)
¶
Source code in src/rnel/nn.py
60 61 62 | |
rnel_from_evidence(e, W=2.0)
¶
Definition 8.1: (T, F, C, U, N, G) = (e_T, e_F, e_C, e_U, e_N, W) / (sum e + W). e: (..., 5).
Source code in src/rnel/nn.py
15 16 17 18 | |
typed_evidential_loss(e, y, W=2.0, reg=0.0, weight=None)
¶
Negative log-likelihood of the observed type under alpha/A, alpha = e + W/M, plus reg * wrong evidence.
Source code in src/rnel/nn.py
32 33 34 35 36 37 38 39 40 41 42 43 44 | |
source_conflict(e, mask, W=2.0)
¶
Largest pairwise conflict b_i d_j + d_i b_j between the per-piece opinions (i < j). e: (B, P, 2).
Source code in src/rnel/nn.py
65 66 67 68 69 70 71 72 73 74 | |
fused_dissonance(E, W=2.0)
¶
Dissonance of the fused binary evidence: 2 min(b, d) = (1 - u)(1 - |b - d| / (b + d)).
Source code in src/rnel/nn.py
77 78 79 80 | |