keras-team / keras-preprocessing

Utilities for working with image data, text data, and sequence data.
Other
1.02k stars 444 forks source link

TimeseriesGenerator object is not an iterator #86

Open srigv opened 5 years ago

srigv commented 5 years ago

hello,

I see an issue with TimeSeriesGenerator.

tensorflow 1.11.0 Keras 2.2.2 Keras-Applications 1.0.6 Keras-Preprocessing 1.0.5

I am using the following code to test the TimeseriesGenerator

data = np.arange(0,100).reshape(-1,1)
data_gen = TimeseriesGenerator(data, data, length=WINDOW_LENGTH,
                               sampling_rate=1, batch_size=1)

data_dim = 1
input1 = Input(shape=(WINDOW_LENGTH, data_dim))
lstm1 = LSTM(100)(input1)
hidden = Dense(20, activation='relu')(lstm1)
output = Dense(data_dim, activation='linear')(hidden)

model = Model(inputs=input1, outputs=output)
model.compile(loss='mse', optimizer='rmsprop', metrics=['accuracy'])

model.fit_generator(generator=data_gen,
                    steps_per_epoch=32,
                    epochs=10)

here is the stacktrace.

TypeErrorTraceback (most recent call last)
<ipython-input-55-ad7e35e8fffd> in <module>()
     16 model.fit_generator(generator=data_gen,
     17                     steps_per_epoch=32,
---> 18                     epochs=10)

/usr/lib/python2.7/site-packages/keras/legacy/interfaces.pyc in wrapper(*args, **kwargs)

/usr/lib/python2.7/site-packages/keras/engine/training.pyc in fit_generator(self, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)

/usr/lib/python2.7/site-packages/keras/engine/training_generator.pyc in fit_generator(model, generator, steps_per_epoch, epochs, verbose, callbacks, validation_data, validation_steps, class_weight, max_queue_size, workers, use_multiprocessing, shuffle, initial_epoch)

/usr/lib/python2.7/site-packages/keras/utils/data_utils.pyc in get(self)

/usr/lib/python2.7/site-packages/keras/utils/data_utils.pyc in _data_generator_task(self)

TypeError: TimeseriesGenerator object is not an iterator

I tried to play around with package versions and I see that issue occurs only when using Keras-Preprocessing >= 1.0.3. I am able to run this code with 1.0.2.

shuangyangwang commented 5 years ago

same issue

Dref360 commented 5 years ago

I think this has been fixed on Keras master?


De : shuangyangwang notifications@github.com Envoyé : 6 novembre 2018 21:42:44 À : keras-team/keras-preprocessing Cc : Subscribed Objet : Re: [keras-team/keras-preprocessing] TimeseriesGenerator object is not an iterator (#86)

same issue

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHubhttps://github.com/keras-team/keras-preprocessing/issues/86#issuecomment-436484534, or mute the threadhttps://github.com/notifications/unsubscribe-auth/AIj4oguaWyQAFJYBWnmda8ausqH55AHBks5uskikgaJpZM4YCzJZ.