Search code examples
jupyter-notebookgoogle-colaboratoryconv-neural-network

How can I run a jupyter notebook, k times and take some result, on google colab?


I have an ipynb on my google colab called Augmented.ipynb

Inside the ipynb a have a cnn that I run with keras

After the cnn runs I have a function that is the following:

def foo():
  best_score = max(history.history['val_accuracy'])
  print(best_score)

I want to run the entire notebook 20 times and take the the best_score each time.

One way I have figured to do this, is to run the jupyter notebook from another notebook on colab, which I've seen is possible. put since I want to run the entire notebook which is not a function, I can't figure out how to do it.

The notebook path is the following: /content/drive/My Drive/Colab Notebooks/Augmented.ipynb


Solution

  • well, one way to do it would be to save all the important code in a function.

    def entire_code():
        # copy all code here
        return result
    
    
    results = []
    for _ in range(20):
        results.append(entire_code())