Google Colab - Where is the output saved?

15,319

Solution 1

First, mount your drive:

!mkdir -p drive
!google-drive-ocamlfuse drive

Now, append your path:

import sys
sys.path.append('drive/Project')

You should be able to see your files on your local and web-based drive using:

model.save('drive/Project/myModel.h5')

Solution 2

Even though it is a bit late, I was also struggling with the same question.Then i found out mounting the drive in colab and then providing the drive path,the files will get stored in the google drive

from google.colab import drive
drive.mount('/content/gdrive')
#using model.save_weights() to save the weights of the model in HDF5 format
model.save_weights("/content/gdrive/My Drive/weights.h5")

The file is saved in the drive with name "weights.h5"

Share:
15,319
Tanmay Bhatnagar
Author by

Tanmay Bhatnagar

Updated on June 08, 2022

Comments

  • Tanmay Bhatnagar
    Tanmay Bhatnagar almost 2 years

    I am training a machine learning model on google's colab. I am using keras with tensorflow backend (python 3.6). I am saving my model using the model.save() function provided by keras. When I call model.save('model_name)` where is the file saved? I cannot find it in my drive anywhere.

  • Tanmay Bhatnagar
    Tanmay Bhatnagar about 6 years
    fuse: mountpoint is not empty fuse: if you are sure this is safe, use the 'nonempty' mount option. How do I empty the mountpoint?
  • Oringa
    Oringa about 6 years
    Maybe this could be of use: stackoverflow.com/questions/20271101/…
  • Tanmay Bhatnagar
    Tanmay Bhatnagar about 6 years
    Gave authorisation and mounted my drive. I am getting this error : Unable to create file (unable to open file: name = 'DL/Project/gen0.h5', errno = 2, error message = 'No such file or directory', flags = 13, o_flags = 242)
  • Sung
    Sung about 4 years
    from google.colab import drive drive.mount('/content/drive')