How to use Keras TensorBoard callback for grid search

后端 未结 2 1440
旧时难觅i
旧时难觅i 2021-01-17 16:54

I\'m using the Keras TensorBoard callback. I would like to run a grid search and visualize the results of each single model in the tensor board. The problem is that all resu

2条回答
  •  北海茫月
    2021-01-17 17:47

    It's easy, just save logs to separate dirs with concatenated parameters string as dir name:

    Here is example using date as name of run:

    from datetime import datetime
    
    datetime_str = ('{date:%Y-%m-%d-%H:%M:%S}'.format(date=datetime.now()))
    callbacks = [
        ModelCheckpoint(model_filepath, monitor='val_loss', save_best_only=True, verbose=0),
        TensorBoard(log_dir='./logs/'+datetime_str, histogram_freq=0, write_graph=True, write_images=True),
    ]
    
    history = model.fit_generator(
        generator=generator.batch_generator(is_train=True),
        epochs=config.N_EPOCHS,
        steps_per_epoch=100,
        validation_data=generator.batch_generator(is_train=False),
        validation_steps=10,
        verbose=1,
        shuffle=False,
        callbacks=callbacks)
    

提交回复
热议问题