abbo0963
2021-07-07 10:10
采纳率: 100%
浏览 16
已采纳

Pytorch 读出测试资料错误

我 下载 https://www.kaggle.com/nsojib/bangla-money 的training资料夹(放在我的云端硬碟)
然后用colab跑下面程式,但读出来的是错的,5块钱读成100块钱 想问可以怎么改


![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/58921832652610.9222606795029527.png)



from google.colab import drive
drive.mount('/content/drive')

import torch
import torch.nn as nn
import torch.nn.functional as F
import torch.optim as optim
import torchvision
import torchvision.transforms as transforms
import matplotlib.pyplot as plt
import numpy as np
import torch.optim as optim
from sklearn.metrics import f1_score
from torchvision import transforms, datasets, utils
from torchvision.datasets import ImageFolder
import pandas as pd
#过滤警告信息
import warnings
warnings.filterwarnings("ignore")
from torch.utils.data import DataLoader,Dataset
from skimage import io,transform
import matplotlib.pyplot as plt
from PIL import Image

data_transform = transforms.Compose([transforms.ToTensor(),  transforms.Normalize(mean=[0.5, 0.5, 0.5],std=[0.5, 0.5, 0.5])])##

train_dataset = datasets.ImageFolder(root='/content/drive/MyDrive/Training',transform=data_transform)
dataset_loader = torch.utils.data.DataLoader(train_dataset,batch_size=16, shuffle=True,  num_workers=2)
train_dataset 

classes = ('1', '2', '5', '10', '20', '50', '100', '500', '1000')

def imshow(img):
    img = img / 2 + 0.5
    npimg = img.numpy()
    plt.imshow(np.transpose(npimg, (1, 2, 0)))
    plt.show()


dataiter = iter(dataset_loader)
images, labels = dataiter.next()

batch_size = 16 
for j in range(batch_size):
 
  print("This label is a "+str(classes[labels[j]]))
  
  imshow(images[j])

![img](https://img-mid.csdnimg.cn/release/static/image/mid/ask/02371832652610.9164533052515305.png)
  • 写回答
  • 好问题 提建议
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • abbo0963 2021-07-07 12:34
    已采纳

    classes = ('1', '10', '100', '1000', '2', '20', '5', '50', '500')

    已采纳该答案
    评论
    解决 无用
    打赏 举报

相关推荐 更多相似问题