__init__() missing 2 required positional arguments: 'labels' and 'transform'
时间: 2023-12-24 10:05:49 浏览: 75
This error message indicates that when creating an object of a class, the constructor method (__init__) is expecting two required arguments - 'labels' and 'transform' - but they are not being provided.
To resolve this error, you need to provide the required arguments when creating an object of the class. For example:
```
from torchvision import datasets, transforms
transform = transforms.Compose([transforms.ToTensor()])
train_data = datasets.MNIST(root='./data', train=True, download=True, transform=transform)
```
In the above example, we are creating an object of the MNIST dataset class from the torchvision module, and providing the required arguments - 'transform' and 'train' - to the constructor method.
阅读全文