When creating a Callback to do some model validation after each epoch and print the result, I realised that Keras will run on_epoch_end
of my Callback before the one from its logger.
So what ends up happening is a log like this:
Epoch 10/10
288/300 [===========================>..] - ETA: 0s - loss: 0.2414
Important message with important stuff
300/300 [==============================] - 0s - loss: 0.2403
Here is the code to generate the above output:
from keras.models import Sequential
from keras.layers.core import Dense
from keras.callbacks import Callback
import numpy as np
class TestCallback(Callback):
def on_epoch_end(self, epoch, logs={}):
print "\nImportant message with important stuff\n"
model = Sequential()
model.add(Dense(10, input_shape=(10,)))
model.compile(loss="mse", optimizer="sgd")
X = np.random.random(size=(300, 10))
Y = np.random.random(size=(300, 10))
model.fit(X, Y, callbacks=[TestCallback()])
The solution in your case is not to use verbose=1
in fit. Prefer
verbose=2
.
On 15 April 2016 at 10:32, Frederico Tommasi Caroli <
[email protected]> wrote:
When creating a Callback to do some model validation after each epoch and
print the result, I realised that Keras will run on_epoch_end of my
Callback before the one from its logger.
So what ends up happening is a log like this:Epoch 10/10
288/300 [===========================>..] - ETA: 0s - loss: 0.2414
Important message with important stuff300/300 [==============================] - 0s - loss: 0.2403
Here is the code to generate the above output:
from keras.models import Sequentialfrom keras.layers.core import Densefrom keras.callbacks import Callback
import numpy as np
class TestCallback(Callback):
def on_epoch_end(self, epoch, logs={}):
print "\nImportant message with important stuff\n"model = Sequential()
model.add(Dense(10, input_shape=(10,)))
model.compile(loss="mse", optimizer="sgd")
X = np.random.random(size=(300, 10))Y = np.random.random(size=(300, 10))model.fit(X, Y, callbacks=[TestCallback()])
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/fchollet/keras/issues/2354
Yeah, sure. But it would be nice to have the possibility of using verbose=1. I'm just pointing out this bug.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed after 30 days if no further activity occurs, but feel free to re-open a closed issue if needed.