Last active
April 23, 2026 14:53
-
-
Save bquast/1ff28491c40ea533093b10d3a49a8daf to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| # NN-1-layer.R | |
| # Bastiaan Quast | |
| # [email protected] | |
| # create data | |
| inputs = matrix(c(0,1,1, | |
| 1,0,1, | |
| 1,0,1, | |
| 1,1,0 ), nrow=4, byrow=TRUE) | |
| true_values = matrix(c(0, | |
| 1, | |
| 1, | |
| 1 ),nrow=4) | |
| # initialize weights | |
| weights = matrix(runif(n = 3, min=-1, max=1), nrow=3) | |
| # run through the training data 60,000 times | |
| for (j in 1:60000) { | |
| predictions = plogis(inputs %*%weights) | |
| weights_update = (true_values - predictions) * (predictions*(1-predictions)) | |
| weights = weights + t(inputs) %*% weights_update | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment