图像分类案例2
# 在本节notebook中,使用后续设置的参数在完整训练集上训练模型,大致需要40-50分钟 # 请大家合理安排GPU时长,尽量只在训练时切换到GPU资源 # 也可以在Kaggle上访问本节notebook: # https://www.kaggle.com/boyuai/boyu-d2l-dog-breed-identification-imagenet-dogs import torch import torch . nn as nn import torch . optim as optim import torchvision import torchvision . transforms as transforms import torchvision . models as models import os import shutil import time import pandas as pd import random # 设置随机数种子 random . seed ( 0 ) torch . manual_seed ( 0 ) torch . cuda . manual_seed ( 0 ) data_dir = '/home/kesci/input/Kaggle_Dog6357/dog-breed-identification' # 数据集目录 label