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
| # Unit-Variance Scaling or Autoscaling | |
| autoscale <- function(X) { | |
| return(apply(X,2, function(x){ (x- mean(x)) / sd(x) })) | |
| } | |
| # Compute the covariance matrix | |
| covariance <- function(X) { | |
| cM <- matrix(NA, ncol(X), ncol(X), dimnames = list(colnames(X), colnames(X))) | |
| for(x in colnames(X)) { |
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
| /* | |
| The most atomic way to train and run inference for a GPT in pure, dependency-free D. | |
| This file is the complete algorithm, | |
| Everything else is just efficiency. | |
| @karpathy | |
| Translation by @DannyArends | |
| */ | |
| import std.algorithm : countUntil, fold, joiner, map, maxElement, min, sort, sum, uniq; |
OlderNewer