Compare commits
No commits in common. "fc1d803c99e31979519c6e92ec66bd9831e58859" and "5aa9313776aff822ce71ee8b42c5dc8f4f3900ba" have entirely different histories.
fc1d803c99
...
5aa9313776
4 changed files with 12 additions and 50 deletions
|
@ -4,8 +4,14 @@
|
||||||
<option name="autoReloadType" value="SELECTIVE" />
|
<option name="autoReloadType" value="SELECTIVE" />
|
||||||
</component>
|
</component>
|
||||||
<component name="ChangeListManager">
|
<component name="ChangeListManager">
|
||||||
<list default="true" id="75a8c215-b746-4a4d-aa16-f3223c12b1ed" name="Changes" comment="Added MAE loss function">
|
<list default="true" id="75a8c215-b746-4a4d-aa16-f3223c12b1ed" name="Changes" comment="Commented out not yet working code">
|
||||||
<change beforePath="$PROJECT_DIR$/src/main/java/ActivationFunctions.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ActivationFunctions.java" afterDir="false" />
|
<change afterPath="$PROJECT_DIR$/src/main/java/ActivationFunctions.java" afterDir="false" />
|
||||||
|
<change afterPath="$PROJECT_DIR$/src/main/java/LossFunctions.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/gradle.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/gradle.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/ActivationLayer.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ActivationLayer.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/ExampleXOR.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/ExampleXOR.java" afterDir="false" />
|
||||||
|
<change beforePath="$PROJECT_DIR$/src/main/java/Network.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/java/Network.java" afterDir="false" />
|
||||||
</list>
|
</list>
|
||||||
<option name="SHOW_DIALOG" value="false" />
|
<option name="SHOW_DIALOG" value="false" />
|
||||||
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
<option name="HIGHLIGHT_CONFLICTS" value="true" />
|
||||||
|
@ -97,14 +103,7 @@
|
||||||
<option name="project" value="LOCAL" />
|
<option name="project" value="LOCAL" />
|
||||||
<updated>1653168727186</updated>
|
<updated>1653168727186</updated>
|
||||||
</task>
|
</task>
|
||||||
<task id="LOCAL-00002" summary="Added MAE loss function">
|
<option name="localTasksCounter" value="2" />
|
||||||
<created>1653176561735</created>
|
|
||||||
<option name="number" value="00002" />
|
|
||||||
<option name="presentableId" value="LOCAL-00002" />
|
|
||||||
<option name="project" value="LOCAL" />
|
|
||||||
<updated>1653176561735</updated>
|
|
||||||
</task>
|
|
||||||
<option name="localTasksCounter" value="3" />
|
|
||||||
<servers />
|
<servers />
|
||||||
</component>
|
</component>
|
||||||
<component name="Vcs.Log.Tabs.Properties">
|
<component name="Vcs.Log.Tabs.Properties">
|
||||||
|
@ -121,8 +120,7 @@
|
||||||
<component name="VcsManagerConfiguration">
|
<component name="VcsManagerConfiguration">
|
||||||
<MESSAGE value="Initial commit" />
|
<MESSAGE value="Initial commit" />
|
||||||
<MESSAGE value="Commented out not yet working code" />
|
<MESSAGE value="Commented out not yet working code" />
|
||||||
<MESSAGE value="Added MAE loss function" />
|
<option name="LAST_COMMIT_MESSAGE" value="Commented out not yet working code" />
|
||||||
<option name="LAST_COMMIT_MESSAGE" value="Added MAE loss function" />
|
|
||||||
</component>
|
</component>
|
||||||
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
<component name="com.intellij.coverage.CoverageDataManagerImpl">
|
||||||
<SUITE FILE_PATH="coverage/JavaNN$ExampleXOR.ic" NAME="ExampleXOR Coverage Results" MODIFIED="1653174521293" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
|
<SUITE FILE_PATH="coverage/JavaNN$ExampleXOR.ic" NAME="ExampleXOR Coverage Results" MODIFIED="1653174521293" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="idea" COVERAGE_BY_TEST_ENABLED="false" COVERAGE_TRACING_ENABLED="false" />
|
||||||
|
|
|
@ -36,20 +36,4 @@ public class ActivationFunctions {
|
||||||
private static double sigma(double value) {
|
private static double sigma(double value) {
|
||||||
return 1 / (1 + Math.exp(-value));
|
return 1 / (1 + Math.exp(-value));
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SimpleMatrix ReLu(SimpleMatrix A) {
|
|
||||||
SimpleMatrix B = new SimpleMatrix(A);
|
|
||||||
for (int i = 0; i < A.getNumElements(); i++) {
|
|
||||||
B.set(i, Math.max(0, A.get(i)));
|
|
||||||
}
|
|
||||||
return B;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SimpleMatrix ReLuPrime(SimpleMatrix A) {
|
|
||||||
SimpleMatrix B = new SimpleMatrix(A);
|
|
||||||
for (int i = 0; i < A.getNumElements(); i++) {
|
|
||||||
B.set(i, A.get(i) < 0 ? 0 : 1);
|
|
||||||
}
|
|
||||||
return B;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ public class FCLayer extends Layer {
|
||||||
public FCLayer(int inputSize, int outputSize) {
|
public FCLayer(int inputSize, int outputSize) {
|
||||||
Random random = new Random();
|
Random random = new Random();
|
||||||
weights = new SimpleMatrix(inputSize, outputSize, true,
|
weights = new SimpleMatrix(inputSize, outputSize, true,
|
||||||
random.doubles((long) inputSize*outputSize, -1, 1).toArray());
|
random.doubles((long) inputSize*outputSize, -0.5, 0.5).toArray());
|
||||||
biases = new SimpleMatrix(1, outputSize, true,
|
biases = new SimpleMatrix(1, outputSize, true,
|
||||||
random.doubles(outputSize, -1, 1).toArray());
|
random.doubles(outputSize, -0.5, 0.5).toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -14,24 +14,4 @@ public class LossFunctions {
|
||||||
public static SimpleMatrix MSEPrime(SimpleMatrix y_true, SimpleMatrix y_pred) {
|
public static SimpleMatrix MSEPrime(SimpleMatrix y_true, SimpleMatrix y_pred) {
|
||||||
return y_true.minus(y_pred).divide((double) y_true.getNumElements()/2);
|
return y_true.minus(y_pred).divide((double) y_true.getNumElements()/2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static double MAE(SimpleMatrix y_true, SimpleMatrix y_pred) {
|
|
||||||
double sum = 0;
|
|
||||||
for (int i = 0; i < y_true.getNumElements(); i++) {
|
|
||||||
sum += Math.abs(y_true.get(i) - y_pred.get(i));
|
|
||||||
}
|
|
||||||
return sum / y_true.getNumElements();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static SimpleMatrix MAEPrime(SimpleMatrix y_true, SimpleMatrix y_pred) {
|
|
||||||
SimpleMatrix result = new SimpleMatrix(y_true);
|
|
||||||
for (int i = 0; i < result.getNumElements(); i++) {
|
|
||||||
if (y_true.get(i) < y_pred.get(i)) {
|
|
||||||
result.set(i, 1d);
|
|
||||||
} else {
|
|
||||||
result.set(i, -1d);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue