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.
Asked
Active
Viewed 1.9k times
3

Tanmay Bhatnagar
- 2,330
- 4
- 30
- 50
-
1Did you mount your Drive? – Oringa Apr 22 '18 at 15:58
-
No, how do I do that? – Tanmay Bhatnagar Apr 22 '18 at 15:58
-
1Check out this guide: https://medium.com/deep-learning-turkey/google-colab-free-gpu-tutorial-e113627b9f5d – Oringa Apr 22 '18 at 16:07
-
So I mounted my drive and when I execute !ls i see the saved model. How do I download it / Where is it saved? I still do not understand :( – Tanmay Bhatnagar Apr 22 '18 at 16:35
2 Answers
6
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')

Oringa
- 360
- 2
- 11
-
fuse: mountpoint is not empty fuse: if you are sure this is safe, use the 'nonempty' mount option. How do I empty the mountpoint? – Tanmay Bhatnagar Apr 22 '18 at 16:56
-
Maybe this could be of use: https://stackoverflow.com/questions/20271101/what-happens-if-you-mount-to-a-non-empty-mount-point-with-fuse – Oringa Apr 22 '18 at 17:02
-
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) – Tanmay Bhatnagar Apr 22 '18 at 17:31
-
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"

mrinali
- 140
- 10