in python 2: X_train, y_train = train_generator.next() X_test, y_test = validation_generator.next() in python 3: X_train, y_train = next(train_generator) X_test, y_test = next(validation_generator)