Reputation: 9120
I built a script that saves my best model to the filesystem and I want it to also log data about the expected performance of the model to a different text file.
Current code:
model = Sequential()
model.add(Dense(64, input_dim=14, init='uniform'))
model.add(LeakyReLU(alpha=0.3))
model.add(BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None))
model.add(Dropout(0.5))
model.add(Dense(64, init='uniform'))
model.add(LeakyReLU(alpha=0.3))
model.add(BatchNormalization(epsilon=1e-06, mode=0, momentum=0.9, weights=None))
model.add(Dropout(0.5))
model.add(Dense(2, init='uniform'))
model.add(Activation('softmax'))
sgd = SGD(lr=0.1, decay=1e-6, momentum=0.9, nesterov=True)
model.compile(loss='binary_crossentropy', optimizer=sgd)
checkpointer = ModelCheckpoint(filepath="/Desktop/SquareSpace/checkpointer", verbose=2, save_best_only=True)
model.fit(X_train, y_train, nb_epoch=100, batch_size=50, show_accuracy=True, validation_split=0.2, verbose = 2, callbacks=[checkpointer])
I currently save my best model as an HDF5 file. Is there a way to log the performance of the best model which is saved in the HDF5 file using Keras in a different text file?
EDIT: Is there a way to use this here http://keras.io/callbacks/?
Upvotes: 1
Views: 567
Reputation: 31895
You can use python logging
module to log your data.python logging
Use FileHandler
to write all your data into a file and also you can use ConsoleHandler
to display all data on console.
TimedRotatingFileHandler
can help you rotate your log file in certain time intervals. For instance: every hour, every day or every week.
Upvotes: 2