##Uncomment if run for the first time
##install.packages("deepnet")
library(deepnet);
time1<-Sys.time();
flush.console();
mnist <- load.mnist("./mnist/")
# the function to normalize the input values
normalize <- function(x) {
return (x/255)
}
# standardization
train_x_n <- apply(mnist$train$x, c(1,2),FUN = normalize)
test_x_n <- apply(mnist$test$x, c(1,2),FUN = normalize)
#training and prediction
dnn <- dbn.dnn.train(train_x_n, mnist$train$yy,
hidden_dropout = 0.6,
hidden = c(300,100,100,100),
numepochs = 5, cd = 3)
err.dnn <- nn.test(dnn, test_x_n, mnist$test$yy);
time2<-Sys.time();
print(c(time1, time2));
#Some output
print(err.dnn)
print(mnist$test$y[1])