Skip to content

Commit cf61915

Browse files
author
Lukas Molzberger
committed
Fixes
1 parent 7a079d0 commit cf61915

File tree

3 files changed

+31
-6
lines changed

3 files changed

+31
-6
lines changed

src/main/java/network/aika/Model.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public Neuron createNeuron(String label, Type type) {
119119

120120

121121
public Neuron createNeuron(String label, Type type, ActivationFunction actF) {
122-
return new INeuron(this, label, null, type, type.getDefaultActivationFunction()).getProvider();
122+
return new INeuron(this, label, null, type, actF).getProvider();
123123
}
124124

125125
public Neuron createNeuron(String label, Type type, String outputText) {

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

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ public Type getType() {
152152
return type;
153153
}
154154

155+
public void setType(Type t) {
156+
this.type = t;
157+
}
158+
155159

156160
public Provider<InputNode> getOutputNode() {
157161
return outputNode;
@@ -214,6 +218,11 @@ public ActivationFunction getActivationFunction() {
214218
}
215219

216220

221+
public void setActivationFunction(ActivationFunction actF) {
222+
activationFunction = actF;
223+
}
224+
225+
217226
public Stream<Activation> getActivations(Document doc) {
218227
ThreadState th = getThreadState(doc.getThreadId(), false);
219228
if(th == null) {
@@ -425,12 +434,12 @@ public Activation addInput(Document doc, Activation.Builder input) {
425434

426435
doc.addInputNeuronActivation(act);
427436
doc.addFinallyActivatedNeuron(act.getINeuron());
428-
437+
/*
429438
if(getType() != INPUT) {
430439
doc.getLinker().linkInput(act);
431440
doc.getLinker().process();
432441
}
433-
442+
*/
434443
propagate(act);
435444

436445
doc.propagate();
@@ -568,7 +577,10 @@ public void write(DataOutput out) throws IOException {
568577

569578
synapseSummary.write(out);
570579

571-
out.writeUTF(activationFunction.name());
580+
out.writeBoolean(activationFunction != null);
581+
if(activationFunction != null) {
582+
out.writeUTF(activationFunction.name());
583+
}
572584

573585
out.writeInt(outputNode.getId());
574586

@@ -625,7 +637,9 @@ public void readFields(DataInput in, Model m) throws IOException {
625637
bias = in.readDouble();
626638
synapseSummary = SynapseSummary.read(in, m);
627639

628-
activationFunction = ActivationFunction.valueOf(in.readUTF());
640+
if(in.readBoolean()) {
641+
activationFunction = ActivationFunction.valueOf(in.readUTF());
642+
}
629643

630644
outputNode = m.lookupNodeProvider(in.readInt());
631645

src/main/java/network/aika/neuron/Neuron.java

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,18 @@ public Type getType() {
6666
return get().getType();
6767
}
6868

69-
/**
69+
70+
public void setType(Type t) {
71+
get().setType(t);
72+
}
73+
74+
public void setActivationFunction(ActivationFunction actF) {
75+
get().setActivationFunction(actF);
76+
}
77+
78+
79+
80+
/**
7081
* Propagate an input activation into the network.
7182
*
7283
* @param doc The current document

0 commit comments

Comments
 (0)