Colaboratoryは一定時間が経過すると仮想環境と切断されてしまい保存したファイルも消えてしまう。Google Driveをマウントしておけば学習済みモデル等をそちらに保存しておくことが出来る。
1.左端のフォルダのアイコンをクリックする。

2.Google Driveのアイコンをクリックする。

3.Google Driveへのアクセスを許可する。

4.My DriveにGoogle Driveのルートフォルダがマウントされる。

5.使用方法
with open('drive/My Drive/test.txt', 'w') as f: