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_action.py 563 B

123456789101112131415161718
  1. import os
  2. import unittest
  3. from fastNLP.core.action import Action, Batchifier, SequentialSampler
  4. class TestAction(unittest.TestCase):
  5. def test_case_1(self):
  6. x = [1, 2, 3, 4, 5, 6, 7, 8]
  7. y = [1, 1, 1, 1, 2, 2, 2, 2]
  8. data = []
  9. for i in range(len(x)):
  10. data.append([[x[i]], [y[i]]])
  11. data = Batchifier(SequentialSampler(data), batch_size=2, drop_last=False)
  12. action = Action()
  13. for batch_x in action.make_batch(data, use_cuda=False, output_length=True, max_len=None):
  14. print(batch_x)

一款轻量级的自然语言处理(NLP)工具包,目标是减少用户项目中的工程型代码,例如数据处理循环、训练循环、多卡运行等