我已经使用Google Colab创建了word2vec。但是,当我尝试使用通常用于保存在计算机上的代码进行保存时,该文件不会出现:
model.init_sims(replace=True)
model_name = "Twitter"
model.save()
答案 0 :(得分:2)
您可以使用Pydrive。 这是示例
!pip install -U -q PyDrive
from pydrive.auth import GoogleAuth
from pydrive.drive import GoogleDrive
from google.colab import auth
from oauth2client.client import GoogleCredentials
# 1. Authenticate and create the PyDrive client.
auth.authenticate_user()
gauth = GoogleAuth()
gauth.credentials = GoogleCredentials.get_application_default()
drive = GoogleDrive(gauth)
# PyDrive reference:
# https://gsuitedevs.github.io/PyDrive/docs/build/html/index.html
# 2. Create & upload a file text file.
uploaded = drive.CreateFile({'title': 'my_model.ckpt'})
uploaded.SetContentString(model.save())
uploaded.Upload()
print('Uploaded file with ID {}'.format(uploaded.get('id')))
# 3. Load a file by ID and print its contents.
downloaded = drive.CreateFile({'id': uploaded.get('id')})
print('Downloaded content "{}"'.format(downloaded.GetContentString()))
有关完整的详细信息,请参见此Notebook