Error while running keras

Hello. I run the followng code:

model <- keras_model_sequential() %>% 
  layer_gru(units = 32, 
            dropout = 0.1, 
            recurrent_dropout = 0.5,
            return_sequences = TRUE,
            input_shape = list(NULL, dim(data)[[-1]])) %>% 
  layer_gru(units = 64, activation = "relu",
            dropout = 0.1,
            recurrent_dropout = 0.5) %>% 
  layer_dense(units = 1)

model %>% compile(
  optimizer = optimizer_rmsprop(),
  loss = "mae"

history <- model %>% fit_generator(
  steps_per_epoch = 50, # changed - real value = 500
  epochs = 20, # changed - real value = 40
  validation_data = val_gen,
  validation_steps = val_steps

But the code hasn't been executed up to the end. Instead of it I receive the following error:

Error in py_call_impl(callable, dots$args, dots$keywords) : 
  StopIteration: Error occurred in generator:

Detailed traceback:

  File "C:\Users\user\AppData\Local\r-miniconda\envs\r-reticulate\lib\site-packages\tensorflow\python\util\", line 324, in new_func
    return func(*args, **kwargs)
  File "C:\Users\user\AppData\Local\r-miniconda\envs\r-reticulate\lib\site-packages\tensorflow\python\keras\engine\", line 1479, in fit_generator
  File "C:\Users\user\AppData\Local\r-miniconda\envs\r-reticulate\lib\site-packages\tensorflow\python\keras\engine\", line 66, in _method_wrapper
    return method(self, *args, **kwargs)
  File "C:\Users\user\AppData\Local\r-miniconda\envs\r-reticulate\lib\site-packages\tensorflow\python\keras\engine\", line 815, in fit
  File "C:\Users\user\AppData\Local\r-miniconda\envs\r-reticulate\lib\site-packages\tensorflow\python\keras\engine\", line 1112, in __init__
  File "C:\Users\user\AppData\Local\r-miniconda\en

Has anyone ever faced such an error? What should I do in order to execute the code and run it successfully?

Thank you for your help.

I don't have a solution but I can empathise with you. Keras implementation of R has this serious problem that it relies on Python so most errors are coming from Python environment, which is not helpful to R programmers.

This topic was automatically closed 21 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.