在Google CloudML上训练Keras模型无法在R中运行

时间:2019-05-30 14:33:13

标签: r machine-learning keras rstudio gcloud

我在Google ML Cloud中训练Keras模型时遇到问题。将数据发送到Google Cloud时卡住了。

我遵循了本教程:https://tensorflow.rstudio.com/tools/cloudml/articles/training.html 这是我的Rstudio配置:

    $citation

    To cite RStudio in publications use:

      RStudio Team (2018). RStudio: Integrated Development for R. RStudio, Inc., Boston, MA URL
      http://www.rstudio.com/.

    A BibTeX entry for LaTeX users is

      @Manual{,
        title = {RStudio: Integrated Development Environment for R},
        author = {{RStudio Team}},
        organization = {RStudio, Inc.},
       address = {Boston, MA},
        year = {2018},
        url = {http://www.rstudio.com/},
      }


    $mode
    [1] "desktop"

    $version
    [1] ‘1.2.1335’

这是我的train.R代码:

library(keras)
mnist <- dataset_mnist()
train_images <- mnist$train$x
train_labels <- mnist$train$y
test_images <- mnist$test$x
test_labels <- mnist$test$y

train_images <- array_reshape(train_images, c(nrow(train_images), 28*28))
test_images <- array_reshape(test_images, c(nrow(test_images), 28*28))

train_labels <- to_categorical(train_labels, 10)
test_labels <- to_categorical(test_labels, 10)

model <- keras_model_sequential()
model %>% layer_dense(units=32, activation='relu', input_shape=c(28*28))  %>% layer_dense(units=10, activation='softmax')

model %>% compile(
  loss = 'categorical_crossentropy',
  optimizer = optimizer_rmsprop(),
  metrics = c('accuracy')
)

model %>% fit(
  train_images, train_labels, 
  epochs = 5, batch_size = 128
)

现在。当我尝试像这样在gogle云中训练它时:

gcloud_install()
#gcloud_init() <- it runs automatically after install
gcloud_install()

job <- cloudml_train('train.R')

我得到以下结果:

Submitting training job to CloudML...

卡住了。我等了15分钟-还是一无所有。我确实尝试过重新安装gcloud-什么也没有。我在做什么错了?

谢谢!

编辑1 我还应该提到,我在Google云控制台中看不到任何日志

0 个答案:

没有答案