-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 73710dc
Showing
22 changed files
with
43,506 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
target/ | ||
!.mvn/wrapper/maven-wrapper.jar | ||
!**/src/main/**/target/ | ||
!**/src/test/**/target/ | ||
|
||
### IntelliJ IDEA ### | ||
.idea/modules.xml | ||
.idea/jarRepositories.xml | ||
.idea/compiler.xml | ||
.idea/libraries/ | ||
*.iws | ||
*.iml | ||
*.ipr | ||
|
||
### Eclipse ### | ||
.apt_generated | ||
.classpath | ||
.factorypath | ||
.project | ||
.settings | ||
.springBeans | ||
.sts4-cache | ||
|
||
### NetBeans ### | ||
/nbproject/private/ | ||
/nbbuild/ | ||
/dist/ | ||
/nbdist/ | ||
/.nb-gradle/ | ||
build/ | ||
!**/src/main/**/build/ | ||
!**/src/test/**/build/ | ||
|
||
### VS Code ### | ||
.vscode/ | ||
|
||
### Mac OS ### | ||
.DS_Store |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
-0.30779064 -0.11988339 0.21006837 0.48366025 0.027321858 -0.3208103 0.20687543 0.4597395 0.24228075 0.46249318 -0.4809847 -0.35293418 -0.22552863 -0.33045918 0.21397136 -0.35107967 0.23396465 0.47500616 0.18155238 0.4322363 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
0.14082673 -0.40868983 -0.024709726 -0.3233395 0.35455197 0.097625956 -0.16446406 -0.3674031 -0.0673621 -0.2148308 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
0.36638698 -0.111338705 -0.28196928 -0.27613354 0.30107862 -0.028524958 -0.64342284 0.35270464 -0.44135 0.071591415 0.12277257 0.348394 -0.008241653 -0.046460714 -0.30686167 -0.61905825 -0.12674114 0.38351807 -0.27559012 -0.2511327 | ||
0.4936019 -0.5685425 0.116411686 0.20801988 -0.1977276 -0.0012066597 0.34004936 -0.5168037 0.49804622 0.5259802 -0.18001957 -0.271705 0.07692847 -0.5320646 -0.51504177 0.58450395 -0.48857433 -0.60006136 0.6742939 -0.25381067 | ||
0.40631506 0.1401135 0.6673145 -0.5735027 0.22399487 0.28001013 0.40400422 0.18887623 -0.058334175 -0.01644563 -0.016555214 -0.35288614 -0.16616665 0.3261699 -0.1806511 -0.08278414 -0.03714714 -0.31807142 -0.5358126 -0.38093758 | ||
0.13797599 -0.14424857 0.29825753 -0.03976522 0.6498257 -0.2890022 -0.07700998 -0.19703439 0.51549846 -0.08980761 -0.017724093 -0.065522134 0.4251227 0.14015302 -0.42326257 -0.094496764 0.21350513 -0.30841625 0.3195116 0.15583916 | ||
-0.23721714 -0.06378106 0.14189686 0.0135865575 -0.16137446 -0.31988472 -0.027995463 -0.4917153 -0.07798508 -0.055689104 -0.07299139 0.3358422 -0.31224555 0.483767 0.6839953 0.080406845 -0.05582057 -0.461042 -0.46382022 0.2974709 | ||
0.13445474 -0.23427147 -0.2389834 0.20653479 0.33018672 -0.39512363 -0.01938143 -0.3572667 0.27603877 0.108057015 -0.010054774 0.49647596 0.17828695 -0.03504971 -0.064571954 -0.40656537 -0.4288492 0.41101915 0.21771714 -0.25679678 | ||
-0.06744745 -0.08651667 0.27657387 0.023940165 -0.34873477 -0.25213164 0.1468239 -0.12327071 -0.4478091 0.6570352 0.5582282 0.6778385 -0.22575188 0.3505717 -0.21985711 -0.20484298 -0.13206692 -0.5086645 0.1869471 -0.2988697 | ||
0.17438063 0.36547676 -0.07429125 0.16180484 -0.22732061 0.4348774 -0.24492918 -0.3274857 -0.35651952 0.38184467 -0.109175995 -0.14720117 0.56861883 -0.38205588 0.2642675 0.5543364 0.5023515 -0.23207542 -0.03440018 -0.12204064 | ||
-0.24434838 0.19652593 0.15170915 -0.06536993 -0.1742611 0.23247719 0.35724777 -0.07121579 0.36941552 -0.37764698 -0.32478374 0.2852862 -0.4487918 0.02041369 -0.33575803 0.16593426 -0.38837287 0.056614436 -0.012501329 -0.082749896 | ||
-0.41855156 0.0029425975 0.28064233 -0.015640926 -0.3093709 0.12042929 0.0812075 0.009912889 0.118127234 -0.33111233 -0.165428 0.3494854 0.278411 -0.48556912 0.5982413 0.1723589 0.2813808 -0.5124341 -0.4347027 0.023336934 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
# Neural Network Implementation for Handwritten Digit Recognition without Using Any Libraries in Java | ||
This Java project implements a neural network from scratch to recognize handwritten digits from 0 to 9, trained on the MNIST dataset. The network architecture, training process, and future enhancements are detailed below. | ||
|
||
## Project Overview | ||
|
||
### Network Architecture | ||
|
||
- **Input Layer:** 784 neurons (28x28 pixel images) | ||
- **Hidden Layer:** 10 neurons, activated by the Rectified Linear Unit (ReLU) function | ||
- **Output Layer:** 10 neurons, activated by the softmax function | ||
|
||
### Training Algorithm | ||
|
||
The neural network is trained using the Stochastic Gradient Descent (SGD) Backpropagation algorithm. It uses the Rectified Linear activation function for the hidden layer and the softmax activation function for the output layer. | ||
|
||
### Future Enhancements | ||
|
||
- **Graphical User Interface (GUI):** | ||
- Implemented using JavaFX. | ||
- Allows users to draw a digit on the screen, which the neural network will then predict. | ||
- **Utils_Multi Class Update:** | ||
- The current implementation runs out of memory. | ||
- An updated version will be released soon. | ||
|
||
|
||
### Additional Features | ||
|
||
- **Test Class:** | ||
- Evaluates the neural network on the MNIST test dataset. | ||
- Calculates and reports the accuracy of the neural network. | ||
|
||
## Technical Details | ||
|
||
- **Programming Language:** Java 22 | ||
- **Build Tool:** Maven | ||
|
||
## Getting Started | ||
|
||
### Prerequisites | ||
|
||
Ensure you have the following installed: | ||
|
||
- Java 22 | ||
- Maven | ||
- OS - Arch Linux x86_64 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" | ||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<groupId>org.example</groupId> | ||
<artifactId>Raw-NN-Digit-Recognition</artifactId> | ||
<version>1.0-SNAPSHOT</version> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.apache.commons</groupId> | ||
<artifactId>commons-csv</artifactId> | ||
<version>1.11.0</version> | ||
</dependency> | ||
</dependencies> | ||
<properties> | ||
<maven.compiler.source>22</maven.compiler.source> | ||
<maven.compiler.target>22</maven.compiler.target> | ||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding> | ||
</properties> | ||
|
||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
package org.example; | ||
|
||
public class DataSet { | ||
private final float[][] features; | ||
private final float[] labels; | ||
|
||
public DataSet(float[][] features, float[] labels) { | ||
this.features = features; | ||
this.labels = labels; | ||
} | ||
|
||
public float[][] getFeatures() { | ||
return features; | ||
} | ||
|
||
public float[] getLabels() { | ||
return labels; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.example; | ||
|
||
public class LayerDense { | ||
float[][] weights; | ||
float[] biases; | ||
private float[][] outputs; | ||
|
||
public LayerDense(int nInputs, int nNeurons) { | ||
this.weights = new float[nNeurons][nInputs]; | ||
this.biases = new float[nNeurons]; | ||
// Initialize weights and biases betwwen -0.5 and 0.5 | ||
for (int i = 0; i < nNeurons; i++) { | ||
for (int j = 0; j < nInputs; j++) { | ||
this.weights[i][j] = (float) (Math.random() - 0.5); | ||
} | ||
this.biases[i] = (float) (Math.random() - 0.5); | ||
} | ||
} | ||
|
||
public void forward(float[][] inputs) { | ||
this.outputs = new float[weights.length][inputs[0].length]; | ||
for (int i = 0; i < weights.length; i++) { | ||
for (int j = 0; j < inputs[0].length; j++) { | ||
float sum = 0; | ||
for (int k = 0; k < inputs.length; k++) { | ||
sum += weights[i][k] * inputs[k][j]; | ||
} | ||
this.outputs[i][j] = sum + biases[i]; | ||
} | ||
} | ||
} | ||
|
||
public float[][] getOutputs() { | ||
return outputs; | ||
} | ||
} |
Oops, something went wrong.