pytorch 迁移学习实战 天气识别

代码:pytorch迁移学习实战,天气识别-深度学习文档类资源-CSDN文库

dataset 

import random
import numpy as np
import torch
from torchvision import transforms
import torchvision

if __name__=='__main__':
    import matplotlib.pyplot as plt
    # 定义数据处理transform
    transform = transforms.Compose([
        transforms.Resize([224,224]),
        transforms.ToTensor()
    ])
    #transform是对特征进行变换,target_transform是对标签进行变换
    dataset=torchvision.datasets.ImageFolder(root='./data',transform=transform,
                                             target_transform=torchvision.transforms.Lambda(lambda x:torch.zeros(4,dtype=torch.float).scatter_(0,torch.tensor(x),value=1)))
    print(dataset.classes)
    print(dataset.class_to_idx)
    print(dataset.imgs

你可能感兴趣的:(深度学习,pytorch,python,深度学习)