text icon indicating copy to clipboard operation
text copied to clipboard

Add padding direction

Open smsm8898 opened this issue 2 years ago • 2 comments

give small flexibility to pad transformer

smsm8898 avatar Mar 18 '23 05:03 smsm8898

@SM-Jang Thanks for the addition! A couple of notes:

  1. Can you refer to our style guide and make sure the code passes our linting?
  2. Can you add a brief note on the motivation behind this addition?

joecummings avatar Mar 20 '23 17:03 joecummings

  1. Can you refer to our style guide and make sure the code passes our linting? Okay, I check flake8 and I follow change the name as begin:bool, default=False To verify it, i modify the unittest and pass it all (test/torchtext_unittest/test_transfoms.py)

  2. Can you add a brief note on the motivation behind this addition? When I work for modeling timeserise, I have to pad on begin or end. The old PadTransform only give left pad... So I have to use torch.nn.functional.pad()

ex) ... self.query_transformer = Sequential( # Truncate(10), VocabTransform(query_vocab), ToTensor(), ) ... x = query_transformer(x) x = torch.nn.functional.pad(x, (0, pad_amount), value=self.pad_value) ...

That's why

smsm8898 avatar Mar 21 '23 02:03 smsm8898