Exemplo n.º 1
0
 def testMakeBatch(self):
     x = [
         {"input": torch.randn(4), "target": "a"},
         {"input": torch.randn(4), "target": "b"},
     ]
     y = transform.makebatch()(x)
     self.assertEqual(y["input"].size(), torch.Size([2, 4]))
     self.assertEqual(y["target"], ["a", "b"])
Exemplo n.º 2
0
 def testMakeBatch(self):
     x = [
         {
             'input': torch.randn(4),
             'target': "a"
         },
         {
             'input': torch.randn(4),
             'target': "b"
         },
     ]
     y = transform.makebatch()(x)
     self.assertEqual(y['input'].size(), torch.Size([2, 4]))
     self.assertEqual(y['target'], ["a", "b"])
Exemplo n.º 3
0
 def __init__(self,
              dataset,
              batchsize,
              perm=lambda idx, size: idx,
              merge=None,
              policy='include-last',
              filter=lambda sample: True):
     super(BatchDataset, self).__init__()
     self.dataset = dataset
     self.perm = perm
     self.batchsize = batchsize
     self.policy = policy
     self.filter = filter
     self.makebatch = transform.makebatch(merge)
     len(self)