0

I´m using keras R, keras_model_sequential, fit_generator and generator_pred. It works well. And I´ve saved the model. But when I use "load_model" and try to use it for "generator_pred" it ends up with this error.

Error occurred in generator: argument 'length.out' must be of length 1 Error in py_call_impl(callable, dots$args, dots$keywords) : StopIteration:

Actually the only different is that I use the reloaded model, everything else is the same. Does someone know why?

Bettina10
  • 23
  • 1
  • 6
  • When asking for help, you should include a simple [reproducible example](https://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example) with sample input and desired output that can be used to test and verify possible solutions. Show the code you are running. – MrFlick Apr 25 '18 at 16:23

1 Answers1

0

You're probably using a "training" generator for "predicting".

  • A training generator outputs X and Y. (that means: length 2)
  • A predicting generator outputs X only (that means: length 1)

If you know how to get elements from a generator in R, you can create another generator that contains the old generator. The new generator gets an element from the old geneartor and outputs only the first element X, discarding Y.

Daniel Möller
  • 84,878
  • 18
  • 192
  • 214