Guest User

Untitled

a guest
Oct 19th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. library(keras)
  2. library(densenet)
  3.  
  4. input_img <- layer_input(shape = c(28, 28, 1))
  5. model <- application_densenet(input_tensor = input_img, classes = 10L)
  6.  
  7. model %>% compile(
  8. optimizer = "adam",
  9. loss = "categorical_crossentropy",
  10. metrics = "accuracy"
  11. )
  12.  
  13. mnist <- dataset_mnist()
  14.  
  15. dim(mnist$train$x) <- c(dim(mnist$train$x), 1)
  16. dim(mnist$test$x) <- c(dim(mnist$test$x), 1)
  17.  
  18. y <- sapply(0:9, function(x) as.numeric(x == mnist$train$y))
  19. y_test <- sapply(0:9, function(x) as.numeric(x == mnist$test$y))
  20.  
  21.  
  22. model %>% fit(
  23. x = mnist$train$x,
  24. y = y,
  25. batch_size = 32,
  26. validation_data = list(mnist$test$x, y_test)
  27. )
Add Comment
Please, Sign In to add comment