# Install and load the required package
# install.packages("keras")
library(keras)
# Download the MNIST dataset
mnist <- dataset_mnist()
# Separate images and labels
train_images <- mnist$train$x
train_labels <- mnist$train$y
# Select an index of the image to view
i <- 1 # you can choose any index from 1:60000
# Display the image
image(
t(apply(train_images[i,,], 2, rev)),
col = gray(seq(0, 1, length = 256)),
main = paste("Label:", train_labels[i])
)

发表评论