Skip to content

Commit

Permalink
Rewritten attention system & Added basic embedding encoding
Browse files Browse the repository at this point in the history
  • Loading branch information
xEcho1337 committed Dec 2, 2024
1 parent cb08e2f commit e04e7ba
Show file tree
Hide file tree
Showing 22 changed files with 320 additions and 1,586 deletions.
2 changes: 2 additions & 0 deletions src/main/java/net/echo/brain4j/activation/Activation.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
public interface Activation {

double activate(double input);

double[] activate(double[] input);

double getDerivative(double input);

void apply(List<Neuron> neurons);
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import java.util.List;

public class SoftmaxActivation implements Activation {

@Override
public double activate(double input) {
throw new UnsupportedOperationException("Softmax activation function is not supported for single value");
Expand All @@ -14,6 +15,7 @@ public double activate(double input) {
@Override
public double[] activate(double[] inputs) {
double maxInput = Double.NEGATIVE_INFINITY;

for (double input : inputs) {
if (input > maxInput) {
maxInput = input;
Expand All @@ -22,13 +24,13 @@ public double[] activate(double[] inputs) {

double[] expValues = new double[inputs.length];
double sum = 0.0;

for (int i = 0; i < inputs.length; i++) {
expValues[i] = Math.exp(inputs[i] - maxInput);
sum += expValues[i];
sum += (expValues[i] = Math.exp(inputs[i] - maxInput));
}

for (int i = 0; i < expValues.length; i++) {
expValues[i] /= sum;
expValues[i] = expValues[i] / sum;
}

return expValues;
Expand Down
21 changes: 0 additions & 21 deletions src/main/java/net/echo/brain4j/nlp/AlphabetInitialization.java

This file was deleted.

91 changes: 0 additions & 91 deletions src/main/java/net/echo/brain4j/nlp/LabelTransformer.java

This file was deleted.

11 changes: 0 additions & 11 deletions src/main/java/net/echo/brain4j/nlp/agents/Agent.java

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit e04e7ba

Please sign in to comment.