使用colabotatory进行深度学习
首先确保当前笔记本设置了GPU/TPU
colabotatory——修改——笔记本设置
连通Colab与Google Drive
在Jupyter Notebook中运行:
!apt-get install -y -qq software-properties-common python-software-properties module-init-tools
!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null
!apt-get update -qq 2>&1 > /dev/null
!apt-get -y install -qq google-drive-ocamlfuse fuse
from google.colab import auth
auth.authenticate_user()
from oauth2client.client import GoogleCredentials
creds = GoogleCredentials.get_application_default()
import getpass
!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL
vcode = getpass.getpass()
!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}
点击运行结果处的链接——复制——粘贴到输入框中(两次)
shift+enter 即可
Mount起自己的Google Drive
输入并运行:
!mkdir -p TerenceDrive
!google-drive-ocamlfuse TerenceDrive
上传文件至TerenceDrive
注意将.py文件中的数据集路径进行修改
找到文件复制路径并修改即可
在colab中运行.py文件
运行:
!python '复制你要运行文件的路径(参考上图)'
eg.
…
#出现了找不到model/xxx.pth文件的问题
#后续尝试将model文件夹上传试试
先写到这里 后续再尝试再更新
参考+感谢!:
https://zhuanlan.zhihu.com/p/34436045