You can not select more than 25 topics Topics must start with a chinese character,a letter or number, can include dashes ('-') and can be up to 35 characters long.

test_batch.py 530 B

1234567891011121314151617
  1. import unittest
  2. from fastNLP.core.batch import Batch
  3. from fastNLP.core.dataset import DataSet
  4. from fastNLP.core.instance import Instance
  5. from fastNLP.core.sampler import SequentialSampler
  6. class TestCase1(unittest.TestCase):
  7. def test(self):
  8. dataset = DataSet([Instance(x=["I", "am", "here"])] * 40)
  9. batch = Batch(dataset, batch_size=4, sampler=SequentialSampler(), use_cuda=False)
  10. for batch_x, batch_y in batch:
  11. print(batch_x, batch_y)
  12. # TODO: weird due to change in dataset.py