-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Closed
Labels
p3-enhancement 🔥Much new such featureMuch new such featuresubmodule-notebook 📓Much web such IDEMuch web such IDEto-merge ↰ImminentImminent
Milestone
Description
Thank you for the tqdm-team for including the tqdm's functionalities for keras' progress bar.
I came across the following bug: the progress bar is always updated in the Jupyter cell it was first generated in. This will be problematic in case you are gathering your keras callbacks into a list somewhere else than in the cell where fit
/ fit_generator
is being called. I attached some pictures to illustrate the behaviour (I left the fit_generator
's verbose on to get a better idea on where the updates should be shown).
Here's some code:
import numpy as np
import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from keras import backend as K
from keras.preprocessing.image import ImageDataGenerator
from keras.datasets import mnist
from keras.utils import to_categorical
from tqdm.keras import TqdmCallback
# params
batch_size = 128
num_classes = 10
epochs = 3
img_rows, img_cols = 28, 28
# data
(x_train, y_train), _ = mnist.load_data()
x_train = x_train[...,np.newaxis]
y_train = to_categorical(y_train, num_classes)
datagen = ImageDataGenerator().flow(x_train, y_train, batch_size=32)
# model
input_shape = (img_rows, img_cols, 1)
model = Sequential()
model.add(Conv2D(32, kernel_size=(3, 3),
activation='relu',
input_shape=input_shape))
model.add(Conv2D(64, (3, 3), activation='relu'))
model.add(MaxPooling2D(pool_size=(2, 2)))
model.add(Dropout(0.25))
model.add(Flatten())
model.add(Dense(128, activation='relu'))
model.add(Dropout(0.5))
model.add(Dense(num_classes, activation='softmax'))
model.compile(loss=keras.losses.categorical_crossentropy,
optimizer=keras.optimizers.Adadelta(),
metrics=['accuracy'])
# START NEW CELL
callbacks = [TqdmCallback()] # or tqdmCallback = TqdmCallback()
# START NEW CELL
# fit the model: iterations update in a wrong cell
model.fit_generator(datagen,
steps_per_epoch=len(datagen),
epochs=epochs,
verbose=1,
callbacks=callbacks) #or callbacks=[tqdmCallback])
Metadata
Metadata
Assignees
Labels
p3-enhancement 🔥Much new such featureMuch new such featuresubmodule-notebook 📓Much web such IDEMuch web such IDEto-merge ↰ImminentImminent