0

i want to reduce the dimension of the MNIST data to 45.

i use keras to import MNIST data

library(keras)
 
mnist <- dataset_mnist()
 
X <- mnist$train$x

Xreduced <- X / 255 

pcaX <- princomp(Xreduced) 

Xfinal <- as.matrix(Xreduced) %*% pcaX$loadings[,1:45]

this last line of code isnt running. i also tried "prcomp" instead of "printcomp" with same issue

error message says

Error in pcaX$loadings[, 1:45] : subscript out of bounds

Duesser
  • 29
  • 7
  • 1
    To change the language of console output use `Sys.setenv(LANG = "en")`: https://stackoverflow.com/questions/13575180/how-to-change-language-settings-in-r Also, why 45 dimensions? What does your scree plot look like? – jared_mamrot Jan 26 '21 at 22:37
  • this code is from a university lecture where this code is shown, but doesnt run. as far as i know 45 is randomly selected, as it is never mentioned how this number is derived – Duesser Jan 26 '21 at 22:42
  • and ofc thank you for your help with the language! – Duesser Jan 26 '21 at 22:51
  • In that case your best option is to go back to your lecturer and ask why it isn't working - it's more likely a typo rather than an actual programming issue. – jared_mamrot Jan 26 '21 at 22:55

0 Answers0