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 553 B

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

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