Skip to content

Commit c0cd903

Browse files
authored
Add deprecation warning in MNIST train[test]_labels[data] (#742)
1 parent 680c745 commit c0cd903

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

torchvision/datasets/mnist.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
from __future__ import print_function
2+
import warnings
23
import torch.utils.data as data
34
from PIL import Image
45
import os
@@ -37,6 +38,26 @@ class MNIST(data.Dataset):
3738
classes = ['0 - zero', '1 - one', '2 - two', '3 - three', '4 - four',
3839
'5 - five', '6 - six', '7 - seven', '8 - eight', '9 - nine']
3940

41+
@property
42+
def train_labels(self):
43+
warnings.warn("train_labels has been renamed targets")
44+
return self.targets
45+
46+
@property
47+
def test_labels(self):
48+
warnings.warn("test_labels has been renamed targets")
49+
return self.targets
50+
51+
@property
52+
def train_data(self):
53+
warnings.warn("train_data has been renamed data")
54+
return self.data
55+
56+
@property
57+
def test_data(self):
58+
warnings.warn("test_data has been renamed data")
59+
return self.data
60+
4061
def __init__(self, root, train=True, transform=None, target_transform=None, download=False):
4162
self.root = os.path.expanduser(root)
4263
self.transform = transform

0 commit comments

Comments
 (0)