Write out file with google colab

Dogemore picture Dogemore · Apr 5, 2018 · Viewed 32.7k times · Source

Was there a way to write out files with google colab? For example, if I use

import requests
r = requests.get(url)

Where will those files be stored? Can they be found? And similarly, can I get the file I outputted via say tensorflow save function

saver=tf.Saver(....)
...
path = saver.save(sess, "./my_model.ckpt")

Thanks!

Answer

korakot picture korakot · Apr 6, 2018

In your first example, the data is still in r.content. So you also need to save them first with open('data.dat', 'wb').write(r.content)

Then you can download them with files.download

from google.colab import files
files.download('data.dat')

Downloading your model is the same:

files.download('my_model.ckpt')