为什么使用colab
1.云端使用,打开即用
2.关联google云端硬盘
3.免费GPU资源。
4.容易分享你的代码,配合教学,学习很方便
例子1::下载图片到你的云端硬盘
from google.colab import drive # Import a library named google.colab
drive.mount('/content/drive', force_remount=True)
%cd /content/drive/MyDrive
#change directory to google drive
!mkdir My #make a directory named My
%cd ./My
#change directory to My
#下载图片到你的硬盘
!gdown --id '1duQU7xqXRsOSPYeOR0zLiSA8g_LCFzoV' --output Minori.jpg
例子2:使用GPU
import torch
torch.cuda.is_available() # is GPU available
# Outputs True if running with GPU