pythonkerasdeep-learningneptune

Is there a way to log the keras model summary to neptune?


I am working on a CNN project and I would like to log the model.summary to neptune.ai. The intention of that is to have an idea about the model parameters while comparing different models. Any help/tips would be much appreciated!


Solution

  • You can log model.summary (assuming it's keras), like this:

    neptune.init('workspace/project')
    neptune.create_experiment()
    
    model = keras.Sequential(...)
    model.summary(print_fn=lambda x: neptune.log_text('model_summary', x))
    

    This will log entire summary as lines of text. You can later browse it in the Logs section of the experiment. Look for tile: "model_summary" in this example.

    Another option - for easier compare - is to log hyper-parameters at experiment creation, like this:

    # Define parameters as Python dict
    PARAMS = {'batch_size': 64,
              'n_epochs': 100,
              'shuffle': True,
              'activation': 'elu'}
    
    # Pass PARAMS dict to params at experiment creation
    neptune.create_experiment(params=PARAMS)
    

    You will have them in Parameters tab of the experiment, like in this example. You will be able to add each parameter as a column to the dashboard for quick compare. Look for greenish columns in this dashboard.