import torchvision
from torch.utils.data import Dataset, DataLoader
from torch import from_numpy, tensor
import numpy as np
trans = transforms.Compose(
[
transforms.Resize(128),
transforms.ToTensor()
])
class UBFCDataset(Dataset):
def __init__(self):
xy = np.loadtxt('/content/drive/My Drive/Subject3hr.csv')
self.x_data = torch.from_numpy(xy[:])
self.len = xy.shape[0]
def __len__(self):
return self.len
def __getitem__(self, index):
train_data_tensor = torchvision.datasets.ImageFolder("/content/drive/My Drive/Meta-rPPG-master/da", transform=trans)
return train_data_tensor[index], self.x_data[index]
dataset = UBFCDataset()
dataset[0]
train_loader = DataLoader(dataset=dataset,batch_size=128,shuffle=True)
for epoch in range(2):
for i, data in enumerate(train_loader, 0):
# get the inputs
inputs, labels = data
print(inputs.shape)
# Run your training process
print(f'Epoch: {i} | Inputs {inputs} | Labels {labels}')
错误:
AttributeError Traceback (most recent call last)
<ipython-input-156-fecbaf453580> in <module>()
4 inputs, labels = data
5
----> 6 print(inputs.shape)
7 # Run your training process
8 print(f'Epoch: {i} | Inputs {inputs} | Labels {labels}')
AttributeError: 'list' object has no attribute 'shape'
答案 0 :(得分:0)
您假设变量类型是一个numpy数组,而实际上是一个原始列表。这是固定代码:
- name: Checkout repo
uses: actions/checkout@v2
with:
repository: 'MyOrg/MyRepo'
ref: ${{env.CURRENT_BRANCH}}