TypeError: '<' not supported between instances of 'int' and 'NumpyArrayIterator' (lesson 2)

I’m wondering if anyone else has run across this error.

It’s happening on Lesson2.ipynb, with the line

fit_model(model, batches, val_batches, nb_epoch=2),


gen=image.ImageDataGenerator() batches = gen.flow(trn_data, trn_labels, batch_size=batch_size, shuffle=True) val_batches = gen.flow(val_data, val_labels, batch_size=batch_size, shuffle=False)


def fit_model(model, batches, val_batches, nb_epoch=1): model.fit_generator(batches, samples_per_epoch=batches, nb_epoch=nb_epoch, validation_data=val_batches, nb_val_samples=val_batches).

I’m thinking it might have something to do with the fact that I’m using a more recent version of VGG whereas things were different when Lesson 2 was originally created. And/or I’ve upgraded Keras in between then and now.

Obviously there is something funky happening with the generator…not sure how to approach it though. Makes sense that you can’t compare and int with a generator object…

That code looks wrong. It says “samples_per_epoch=batches” but it should be “samples_per_epoch=batches.N” (or something similar). Ditto for nb_val_samples.

1 Like