keras 使用时的一些注意事项

  1. fit 时显示的loss
    训练时显示的loss和acc,是已经运行过的batch的平均loss。
    https://github.com/keras-team/keras/issues/10426
  1. 保存每个epoch的model
    filepath = 'saved-model-{epoch:02d}.h5'
    checkpointer = ModelCheckpoint(filepath=filepath, verbose=1, save_best_only=False, save_weights_only=False)

如果filepath是一个固定的字符串,那只会保存最新的model文件。

  1. 显存自适应,而不是一下占满
import tensorflow as tf
from keras.backend.tensorflow_backend import set_session
config = tf.ConfigProto()
config.gpu_options.allow_growth = True  # dynamically grow the memory used on the GPU
config.log_device_placement = False  # to log device placement (on which device the operation ran)
                                    # (nothing gets printed in Jupyter, only if you run it standalone)
sess = tf.Session(config=config)
set_session(sess) 

你可能感兴趣的:(Keras)