【问题标题】:Loading MNIST data in R在 R 中加载 MNIST 数据
【发布时间】:2021-12-21 16:31:25
【问题描述】:

我正在尝试下载 Mnist 数据以便进一步使用它。我需要查看此数据集的前 9 个数字,但收到错误消息。这是我的代码:

install.packages("tensorflow")
library(tensorflow)
datasets <- tf$contrib$learn$datasets
mnist <- datasets$mnist$read_data_sets("MNIST-data", one_hot = TRUE)
Data = mnist$train$images[1:5000,]
Labels = mnist$train$labels[1:5000,]%*%matrix(0:9, nrow = 10)

这是一个错误:enter image description here

【问题讨论】:

  • 错误很明显:“找不到 Python 模块 tensorflow”。您是否验证了 TensorFlow 已正确安装在 R 中?
  • 您没有有效的 python / tensorflow 安装。在我的机器上,它鼓励安装miniconda
  • @MauritsEvers 我如何检查这个?
  • @Mossa miniconda 已安装
  • 尝试再次运行它。您的屏幕截图清楚地表明缺少 R 版本。如果你在 Windows 上安装了一些东西,你必须重新启动一切以确保所有路径、环境等都已刷新。

标签: r tensorflow dataset mnist


【解决方案1】:

我通过scoop安装了miniconda,即

scoop install miniconda3

然后建议我运行conda install -n root -c pscondaenvs pscondaenvs。 首先,我关闭了当前的cmd/terminal。打开一个新的并运行

conda install -n root -c pscondaenvs pscondaenvs

然后重新运行你上面的代码,得到一个错误,说Tensorflow 模块没有安装。 然后我在cmd/终端中运行conda install tensorflow。 (但建议在 R 中使用tensorflow::install_tensorflow(),也许可以在这里尝试)。

现在,接下来的事实是 contrib 不再是 tensorflow 模块的一部分。但这是您可以使用 tfds 获得 MNIST 的地方。我必须遵循的安装说明:

remotes::install_github("rstudio/tfds")
tfds::install_tfds()
mnist <- tfds::tfds_load("mnist")

【讨论】:

    猜你喜欢
    • 2018-05-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-06-13
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多