Skip to content

Commit d1b9f5f

Browse files
author
lukas.molzberger
committed
- Added TypeDescription field to neurons
1 parent be23bc2 commit d1b9f5f

File tree

5 files changed

+42
-10
lines changed

5 files changed

+42
-10
lines changed

core/src/main/java/network/aika/elements/neurons/Neuron.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ public abstract class Neuron<N extends Neuron, A extends Activation> implements
7575

7676
private String label;
7777

78+
private String typeDescription;
79+
7880
private Writable customData;
7981

8082
protected Field bias = initBias();
@@ -429,6 +431,10 @@ public void write(DataOutput out) throws IOException {
429431
if(label != null)
430432
out.writeUTF(label);
431433

434+
out.writeBoolean(typeDescription != null);
435+
if(typeDescription != null)
436+
out.writeUTF(typeDescription);
437+
432438
bias.write(out);
433439

434440
for (Synapse s : getProvider().getInputSynapsesStoredAtOutputSide()) {
@@ -476,6 +482,9 @@ public void readFields(DataInput in, Model m) throws Exception {
476482
if(in.readBoolean())
477483
label = in.readUTF();
478484

485+
if(in.readBoolean())
486+
typeDescription = in.readUTF();
487+
479488
bias.readFields(in);
480489

481490
while (in.readBoolean()) {
@@ -588,6 +597,16 @@ public String getLabel() {
588597
return label;
589598
}
590599

600+
public String getTypeDescription() {
601+
return typeDescription;
602+
}
603+
604+
public <R extends N> R setTypeDescription(String typeDescription) {
605+
this.typeDescription = typeDescription;
606+
607+
return (R) this;
608+
}
609+
591610
public <R extends N> R setLabel(String label) {
592611
this.label = label;
593612
return (R) this;

debugger/src/main/java/network/aika/debugger/neurons/properties/neurons/NeuronPropertyPanel.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ public NeuronPropertyPanel(E n, Activation ref) {
3737
addConstant("Type: ", "" + n.getType());
3838
addConstant("Label: ", n.getLabel());
3939

40+
if(n.getTypeDescription() != null)
41+
addConstant("Type-Description: ", n.getTypeDescription());
42+
4043
n.getBindingSignalSlots().forEach(bsSlot ->
4144
addConstant("BS-Slot-Type: ", "" + bsSlot)
4245
);

text/src/main/java/network/aika/meta/entities/EntityModel.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,8 @@ public void initTemplateNeurons() {
127127
.setLabel(getAbstractLabel(PATTERN, label))
128128
.setTargetNet(ENTITY_NET_TARGET)
129129
.setBias(ENTITY_NET_TARGET)
130-
.setPersistent(true);
130+
.setPersistent(true)
131+
.setTypeDescription("Abstract Entity Pattern Neuron");
131132

132133
entityPattern.makeAbstract()
133134
.setWeight(getDefaultInputCategorySynapseWeight(entityPattern.getType()))
@@ -148,7 +149,7 @@ public void initTemplateNeurons() {
148149
10.0,
149150
BINDING_NET_TARGET,
150151
true
151-
);
152+
).setTypeDescription("Abstract Phrase -> Entity BN");
152153

153154
entityBN.makeAbstract()
154155
.setWeight(getDefaultInputCategorySynapseWeight(entityBN.getType()))
@@ -165,7 +166,8 @@ public void initTemplateNeurons() {
165166

166167
inhibitoryN = new InhibitoryNeuron(getModel(), TEMPLATE_MODEL)
167168
.setLabel(getAbstractLabel(INHIBITORY, label))
168-
.setPersistent(true);
169+
.setPersistent(true)
170+
.setTypeDescription("Abstract Phrase -> Entity InhibN");
169171

170172
inhibitoryN.makeAbstract()
171173
.setWeight(1.0);
@@ -180,7 +182,7 @@ public void initTemplateNeurons() {
180182
getModel(),
181183
"Topic (Entity)",
182184
BINDING_NET_TARGET
183-
);
185+
).setTypeDescription("Abstract Topic -> Entity BN");
184186

185187
topicBN.makeAbstract()
186188
.setWeight(getDefaultInputCategorySynapseWeight(topicBN.getType()))

text/src/main/java/network/aika/meta/sequences/PhraseModel.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,8 @@ public void initStaticNeurons() {
7272
.setLabel("Upper Case")
7373
.setPersistent(true);
7474

75-
entityBN = addBindingNeuron(model, "Entity (Phrase)", 2.5);
75+
entityBN = addBindingNeuron(model, "Entity (Phrase)", 2.5)
76+
.setTypeDescription("Abstract Entity -> Phrase BN");
7677

7778
entityBN.makeAbstract()
7879
.setWeight(getDefaultInputCategorySynapseWeight(entityBN.getType()))
@@ -91,8 +92,12 @@ public void initOuterSynapses() {
9192

9293
@Override
9394
protected void initTemplateBindingNeurons() {
94-
subPhraseBN = createSubPhraseBindingNeuron();
95-
primaryBN = createPrimaryBindingNeuron();
95+
subPhraseBN = createSubPhraseBindingNeuron()
96+
.setTypeDescription("Abstract Sub-Phrase BN");
97+
98+
primaryBN = createPrimaryBindingNeuron()
99+
.setTypeDescription("Abstract Primary Phrase BN");
100+
96101

97102
expandContinueBindingNeurons(
98103
1,

text/src/main/java/network/aika/meta/topics/TopicModel.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ public void initTemplateNeurons() {
143143
.setLabel("Abstract Topic")
144144
.setTargetNet(TOPIC_NET_TARGET)
145145
.setBias(TOPIC_NET_TARGET)
146-
.setPersistent(true);
146+
.setPersistent(true)
147+
.setTypeDescription("Abstract Topic PN");
147148

148149
topicPatternN.makeAbstract()
149150
.setWeight(getDefaultInputCategorySynapseWeight(topicPatternN.getType()))
@@ -154,7 +155,8 @@ public void initTemplateNeurons() {
154155
model,
155156
"Abstract Topic",
156157
BINDING_NET_TARGET
157-
);
158+
)
159+
.setTypeDescription("Abstract Entity -> Topic BN");
158160

159161
topicBN.makeAbstract()
160162
.setWeight(getDefaultInputCategorySynapseWeight(topicBN.getType()))
@@ -171,7 +173,8 @@ public void initTemplateNeurons() {
171173

172174
inhibitoryN = new InhibitoryNeuron(getModel(), TEMPLATE_MODEL)
173175
.setLabel(getAbstractLabel(INHIBITORY, label))
174-
.setPersistent(true);
176+
.setPersistent(true)
177+
.setTypeDescription("Abstract Entity -> Topic InhibN");
175178

176179
inhibitoryN.makeAbstract()
177180
.setWeight(1.0);

0 commit comments

Comments
 (0)