ruta icon indicating copy to clipboard operation
ruta copied to clipboard

Support for differently shaped data (e.g. CIFAR10)

Open seonghobae opened this issue 7 years ago • 1 comments

Hello, there!

I want to use this awesome software to learning CIFAR10 structured data. Could you support them?

Best, Seongho

seonghobae avatar Jun 27 '18 10:06 seonghobae

Hi!

Thanks for the suggestion. Currently autoencoders defined in Ruta can only treat one-dimensional instances. You could flatten the data beforehand, like in the following example:

library(ruta)
library(purrr)

cifar10 <- keras::dataset_cifar10()
cifar_shape <- as.integer(dim(cifar10$train$x)[-1])

x_train <- keras::array_reshape(
  cifar10$train$x, c(nrow(cifar10$train$x), prod(cifar_shape))
) / 255.0
x_test <- keras::array_reshape(
  cifar10$test$x, c(nrow(cifar10$test$x), prod(cifar_shape))
) / 255.0

ae <-
  autoencoder(
    input() +
      dense(100) + dense(10) + dense(100) +
      output("sigmoid")
  ) %>%
  train(x_train, epochs = 40)
decoded <- ae %>% reconstruct(x_test)

I know this is cumbersome and am working in a simpler solution which allows for treatment of differently shaped data.

Regards, David

fdavidcl avatar Aug 10 '18 10:08 fdavidcl