mlverse / luz

Higher Level API for torch
https://mlverse.github.io/luz/
Other
79 stars 12 forks source link

MNIST example error: missing value where TRUE/FALSE needed #101

Closed MislavSag closed 1 year ago

MislavSag commented 2 years ago

When trying to run MNIST example:

# Packages ----------------------------------------------------------------
[library](https://rdrr.io/r/base/library.html)([torch](https://torch.mlverse.org/docs))
[library](https://rdrr.io/r/base/library.html)([torchvision](https://torchvision.mlverse.org/))
[library](https://rdrr.io/r/base/library.html)([luz](https://mlverse.github.io/luz/))

# Datasets and loaders ----------------------------------------------------

dir <- "~/Downloads/mnist" # caching directory

# Modify the MNIST dataset so the target is identical to the input.
mnist_dataset2 <- torch::[dataset](https://rdrr.io/pkg/torch/man/dataset.html)(
  inherit = mnist_dataset,
  .getitem = function(i) {
    output <- super$.getitem(i)
    output$y <- output$x
    output
  }
)

train_ds <- mnist_dataset2(
  dir,
  download = TRUE,
  transform = transform_to_tensor
)

I get an error:

Error in if (!tools::md5sum(destpath) == r[2]) runtime_error("MD5 sums are not identical for file: {r[1]}.") : 
  missing value where TRUE/FALSE needed
dfalbel commented 1 year ago

This is because downloading MNIST wasn't sucessfull. You can increase the download timeout with options(timeout = 600), delete files in "~/Downloads/mnist" and retry.