提交 5e9838b3 编写于 作者: D dengkaipeng

fix undefined var in test_batch_sampler. test=develop

上级 1238115e
...@@ -22,6 +22,8 @@ from paddle.io import BatchSampler, Dataset, Sampler, SequenceSampler, \ ...@@ -22,6 +22,8 @@ from paddle.io import BatchSampler, Dataset, Sampler, SequenceSampler, \
RandomSampler, WeightedRandomSampler RandomSampler, WeightedRandomSampler
from paddle.io import DistributedBatchSampler from paddle.io import DistributedBatchSampler
IMAGE_SIZE = 32
class RandomDataset(Dataset): class RandomDataset(Dataset):
def __init__(self, sample_num, class_num): def __init__(self, sample_num, class_num):
...@@ -31,7 +33,7 @@ class RandomDataset(Dataset): ...@@ -31,7 +33,7 @@ class RandomDataset(Dataset):
def __getitem__(self, idx): def __getitem__(self, idx):
np.random.seed(idx) np.random.seed(idx)
image = np.random.random([IMAGE_SIZE]).astype('float32') image = np.random.random([IMAGE_SIZE]).astype('float32')
label = np.random.randint(0, CLASS_NUM - 1, (1, )).astype('int64') label = np.random.randint(0, self.class_num - 1, (1, )).astype('int64')
return image, label return image, label
def __len__(self): def __len__(self):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册