R语言显示MNIST图像和标签

# 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])  
)

评论

发表评论

了解 数据控|突破是我们的每一步 的更多信息

立即订阅以继续阅读并访问完整档案。

继续阅读