# install.packages("keras")
# library("keras")
# install_keras(tensorflow = "gpu")
# install.packages("pROC")
library(keras)
library(grid)
?dataset_cifar10
cifar <- dataset_cifar10()
names(cifar)
## [1] "train" "test"
c(train_images, train_labels) %<-% cifar$train
c(test_images, test_labels) %<-% cifar$test
dim(train_images)
## [1] 50000 32 32 3
length(train_labels)
## [1] 50000
table(train_labels)
## train_labels
## 0 1 2 3 4 5 6 7 8 9
## 5000 5000 5000 5000 5000 5000 5000 5000 5000 5000
dim(test_images)
## [1] 10000 32 32 3
10 Classes: airplane, automobiel, bird, cat, deer, dog, frog, horse, ship, truck.
n = nrow(train_images)
for(i in 0:9){
ind = sample((1:n)[which(train_labels == i)], 10)
for(j in 1:10){
img = train_images[ind[j], , , ] / 255
grid.raster(img, x=(i+1)/11, y=j/11, height = 0.09)
}
}