Skip to content

Commit 1443ee0

Browse files
author
Lukas Molzberger
committed
removed activations set from the interpretation node
1 parent 168e432 commit 1443ee0

File tree

4 files changed

+24
-46
lines changed

4 files changed

+24
-46
lines changed

src/main/java/org/aika/corpus/Document.java

Lines changed: 10 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,9 @@ public void generateCandidates() {
190190
}
191191

192192
long v = visitedCounter++;
193-
markCandidateSelected(bottom, v);
193+
for(Activation act: inputNeuronActivations) {
194+
act.visited = v;
195+
}
194196

195197
i = 0;
196198
candidates = new ArrayList<>();
@@ -202,7 +204,7 @@ public void generateCandidates() {
202204
c.id = i++;
203205
candidates.add(c);
204206

205-
markCandidateSelected(c.refinement, v);
207+
c.refinement.activation.visited = v;
206208
break;
207209
}
208210
}
@@ -216,15 +218,6 @@ public void generateCandidates() {
216218
}
217219

218220

219-
private static void markCandidateSelected(InterpretationNode n, long v) {
220-
if (n.activations != null) {
221-
for (Activation act : n.activations) {
222-
act.visited = v;
223-
}
224-
}
225-
}
226-
227-
228221
/**
229222
* The method <code>process</code> needs to be called after all the input activations have been added to the
230223
* network. It performs the search for the best interpretation.
@@ -488,13 +481,11 @@ public void propagateActivationValue(int round, Activation act) {
488481
}
489482

490483

491-
private void addAll(Collection<Activation> acts) {
492-
for(Activation act: acts) {
493-
add(0, act);
494-
for(Activation.SynapseActivation sa: act.neuronOutputs) {
495-
if(sa.synapse.key.isRecurrent) {
496-
add(0, sa.output);
497-
}
484+
private void add(Activation act) {
485+
add(0, act);
486+
for (Activation.SynapseActivation sa : act.neuronOutputs) {
487+
if (sa.synapse.key.isRecurrent) {
488+
add(0, sa.output);
498489
}
499490
}
500491
}
@@ -521,7 +512,7 @@ public Weight process(SearchNode sn) {
521512
long v = visitedCounter++;
522513

523514
if(sn.getParent() != null && sn.getParent().candidate != null) {
524-
addAll(sn.getParent().candidate.refinement.getActivations());
515+
add(sn.getParent().candidate.refinement.activation);
525516
}
526517

527518
Weight delta = Weight.ZERO;

src/main/java/org/aika/corpus/InterpretationNode.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,6 @@ public class InterpretationNode implements Comparable<InterpretationNode> {
9898
public Conflicts conflicts = new Conflicts();
9999

100100
public NavigableMap<Key, NodeActivation> nodeActivations;
101-
public NavigableSet<Activation> activations;
102101

103102

104103
public enum State {
@@ -310,11 +309,6 @@ public Collection<NodeActivation> getNodeActivations() {
310309
}
311310

312311

313-
public Collection<Activation> getActivations() {
314-
return activations != null ? activations : Collections.emptySet();
315-
}
316-
317-
318312
public static InterpretationNode add(Document doc, boolean nonConflicting, InterpretationNode... input) {
319313
ArrayList<InterpretationNode> in = new ArrayList<>();
320314
for (InterpretationNode n : input) {

src/main/java/org/aika/corpus/SearchNode.java

Lines changed: 14 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -486,24 +486,22 @@ private boolean checkPrecondition() {
486486

487487

488488
private void invalidateCachedDecisions(long v) {
489-
for (Activation act : candidate.refinement.activations) {
490-
for (SynapseActivation sa : act.neuronOutputs) {
491-
if (!sa.synapse.isNegative()) {
492-
Candidate posCand = sa.output.key.interpretation.candidate;
493-
if (posCand != null) {
494-
if (posCand.cachedDecision == Boolean.FALSE && candidate.id > posCand.id) {
495-
posCand.cachedDecision = null;
496-
}
489+
for (SynapseActivation sa : candidate.refinement.activation.neuronOutputs) {
490+
if (!sa.synapse.isNegative()) {
491+
Candidate posCand = sa.output.key.interpretation.candidate;
492+
if (posCand != null) {
493+
if (posCand.cachedDecision == Boolean.FALSE && candidate.id > posCand.id) {
494+
posCand.cachedDecision = null;
497495
}
496+
}
498497

499-
ArrayList<InterpretationNode> conflicting = new ArrayList<>();
500-
Conflicts.collectConflicting(conflicting, sa.output.key.interpretation, v);
501-
for (InterpretationNode c : conflicting) {
502-
Candidate negCand = c.candidate;
503-
if (negCand != null) {
504-
if (negCand.cachedDecision == Boolean.TRUE && candidate.id > negCand.id) {
505-
negCand.cachedDecision = null;
506-
}
498+
ArrayList<InterpretationNode> conflicting = new ArrayList<>();
499+
Conflicts.collectConflicting(conflicting, sa.output.key.interpretation, v);
500+
for (InterpretationNode c : conflicting) {
501+
Candidate negCand = c.candidate;
502+
if (negCand != null) {
503+
if (negCand.cachedDecision == Boolean.TRUE && candidate.id > negCand.id) {
504+
negCand.cachedDecision = null;
507505
}
508506
}
509507
}

src/main/java/org/aika/neuron/INeuron.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -625,11 +625,6 @@ public void register(Activation act) {
625625
TreeMap<NodeActivation.Key, Activation> actRid = th.activationsRid;
626626
if (actRid != null) actRid.put(ak, act);
627627

628-
if(ak.interpretation.activations == null) {
629-
ak.interpretation.activations = new TreeSet<>();
630-
}
631-
ak.interpretation.activations.add(act);
632-
633628
if (ak.rid != null) {
634629
doc.activationsByRid.put(ak, act);
635630
}

0 commit comments

Comments
 (0)