1

I am training some deep learning code from this repository on a Google Colab notebook. The training is ongoing and seems like it is going to take a day or two.

I am new to deep learning, but my question:

Once the Google Colab notebook has finished running the training script, does this mean that the resulting weights and biases will be hard written to a model somewhere (in the repository folder that I have on my Google Drive), and therefore I can then run the code on any test data I like at any point in the future? Or, once I close the Google Colab notebook, do I lose the weight and bias information and would have to run the training script again if I wanted to use the neural network?

I realise that this might depend on the details of the script (again, the repository is here), but I thought that there might be a general way that these things work also.

Any help in understanding would be greatly appreciated.

OverLordGoldDragon
  • 1
  • 9
  • 53
  • 101
user1551817
  • 6,693
  • 22
  • 72
  • 109
  • 2
    You can use various weight saving techniques to save weights. I am not aware that colab is saving weights on its own, if you use keras you can use `model.save_weights(Path)`, there are other options for other framework. Otherwise start using random state. Thats is what I will advise – WiLL_K Jan 07 '20 at 15:23

1 Answers1

4

No; Colab comes with no built-in checkpointing; any saving must be done by the user - so unless the repository code does so, it's up to you.

Note that the repo would need to figure out how to connect to a remote server (or connect to your local device) for data transfer; skimming through its train.py, there's no such thing.


How to save model? See this SO; for a minimal version - the most common, and a reliable option is to "mount" your Google Drive onto Colab, and point save/load paths to direct

from google.colab import drive
drive.mount('/content/drive') # this should trigger an authentication prompt
%cd '/content/drive/My Drive/'
# alternatively, %cd '/content/drive/My Drive/my_folder/'

Once cd'd into, for example, DL Code in your My Drive (see below), you can simply do model.save("model0.h5"), and this will create model0.h5 in DL Code, containing entire model architecture & its optimizer. For just weights, use model.save_weights().

OverLordGoldDragon
  • 1
  • 9
  • 53
  • 101